Skip to content

Commit 3895f77

Browse files
burnout87bsipocz
authored andcommitted
fixing fixture for test_desi
1 parent 6341094 commit 3895f77

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

astroquery/desi/tests/test_desi.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,9 @@ def patch_get_readable_fileobj(request):
4040
@contextmanager
4141
def get_readable_fileobj_mockreturn(filename, **kwargs):
4242
file_obj = data_path(DATA_FILES['dummy_hdu_list_fits']) # TODO: add images option
43-
f = None
44-
try:
45-
f = open(file_obj, 'rb')
43+
# f = None
44+
with open(file_obj, 'rb') as f:
4645
yield f
47-
finally:
48-
if f is not None:
49-
f.close()
5046

5147
mp = request.getfixturevalue("monkeypatch")
5248

@@ -73,7 +69,8 @@ def get_mockreturn(method, url, params=None, timeout=10, **kwargs):
7369
filename = data_path(DATA_FILES['dummy_tractor_fits'])
7470

7571
if filename is not None:
76-
content = open(filename, 'rb').read()
72+
with open(filename, 'rb') as f:
73+
content = f.read()
7774
return MockResponse(content)
7875

7976

0 commit comments

Comments
 (0)