diff --git a/astroquery/desi/tests/test_desi.py b/astroquery/desi/tests/test_desi.py index df62bb2bde..75f58e025e 100644 --- a/astroquery/desi/tests/test_desi.py +++ b/astroquery/desi/tests/test_desi.py @@ -96,9 +96,9 @@ def compare_result_data(result, data): def image_tester(images, filetype): assert type(images) == list - data = fits.open(data_path(DATA_FILES[filetype])) - assert images[0][0].header == data[0].header - assert np.array_equal(images[0][0].data, data[0].data) + with fits.open(data_path(DATA_FILES[filetype])) as data: + assert images[0][0].header == data[0].header + assert np.array_equal(images[0][0].data, data[0].data) def test_coords_query_region(patch_tap, coords=coords, radius=radius):