Skip to content

Commit 7d79d27

Browse files
burnout87bsipocz
authored andcommitted
fixing fixture for test_desi
1 parent d533bea commit 7d79d27

File tree

1 file changed

+5
-13
lines changed

1 file changed

+5
-13
lines changed

astroquery/desi/tests/test_desi.py

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -40,18 +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-
encoding = kwargs.get('encoding', None)
44-
f = None
45-
try:
46-
if encoding == 'binary':
47-
f = open(file_obj, 'rb')
48-
yield f
49-
else:
50-
f = open(file_obj, 'rb')
51-
yield f
52-
finally:
53-
if f is not None:
54-
f.close()
43+
# f = None
44+
with open(file_obj, 'rb') as f:
45+
yield f
5546

5647
mp = request.getfixturevalue("monkeypatch")
5748

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

8071
if filename is not None:
81-
content = open(filename, 'rb').read()
72+
with open(filename, 'rb') as f:
73+
content = f.read()
8274
return MockResponse(content)
8375

8476

0 commit comments

Comments
 (0)