@@ -78,13 +78,15 @@ def test_esasky_get_images_obs_id(self, tmp_path, mission, obsid):
78
78
result = ESASky .get_images (observation_ids = obsid ,
79
79
missions = mission , download_dir = tmp_path )
80
80
81
- assert Path (tmp_path , mission ).exists ()
81
+ assert Path (tmp_path , mission . upper () ).exists ()
82
82
if mission == "Herschel" :
83
83
assert isinstance (result [mission .upper ()][0 ]["250" ], HDUList )
84
84
assert isinstance (result [mission .upper ()][0 ]["350" ], HDUList )
85
85
assert isinstance (result [mission .upper ()][0 ]["500" ], HDUList )
86
86
else :
87
87
assert isinstance (result [mission .upper ()][0 ], HDUList )
88
+ for hdu_list in result [mission .upper ()]:
89
+ hdu_list .close ()
88
90
89
91
@pytest .mark .parametrize ("mission, observation_id" ,
90
92
zip (["ISO-IR" , "Chandra" , "IUE" , "XMM-NEWTON" ,
@@ -95,12 +97,13 @@ def test_esasky_get_spectra_obs_id(self, tmp_path, mission, observation_id):
95
97
result = ESASky .get_spectra (observation_ids = observation_id ,
96
98
missions = mission , download_dir = tmp_path )
97
99
98
- assert Path (tmp_path , mission ).exists ()
100
+ assert Path (tmp_path , mission . upper () ).exists ()
99
101
if mission == "Herschel" :
100
102
assert isinstance (result [mission .upper ()]["1342253595" ]["WBS" ]["WBS-V_USB_4b" ], HDUList )
101
103
assert isinstance (result [mission .upper ()]["1342253595" ]["HRS" ]["HRS-H_LSB_4b" ], HDUList )
102
104
else :
103
105
assert isinstance (result [mission .upper ()][0 ], HDUList )
106
+ result [mission .upper ()][0 ].close ()
104
107
105
108
def test_esasky_query_region_maps (self ):
106
109
result = ESASky .query_region_maps (position = "M51" , radius = "5 arcmin" )
@@ -115,10 +118,13 @@ def test_esasky_query_object_maps(self):
115
118
'ISO-IR' , 'Herschel' , 'JWST-MID-IR' ,
116
119
'JWST-NEAR-IR' , 'Spitzer' ])
117
120
def test_esasky_get_images (self , tmp_path , mission ):
118
- ESASky .get_images (position = "M51" , missions = mission , download_dir = tmp_path )
119
-
121
+ result = ESASky .get_images (position = "M51" , missions = mission , download_dir = tmp_path )
120
122
assert tmp_path .stat ().st_size
121
123
124
+ if mission != "Herschel" and result :
125
+ for hdu_list in result [mission .upper ()]:
126
+ hdu_list .close ()
127
+
122
128
@pytest .mark .bigdata
123
129
def test_esasky_get_images_hst (self , tmp_path ):
124
130
ESASky .get_images (position = "M11" , radius = "2.1 deg" , missions = "HST-UV" ,
@@ -141,12 +147,16 @@ def test_esasky_get_maps(self, tmp_path):
141
147
iso_maps = ESASky .query_object_maps (position = "M51" , missions = mission )
142
148
# Remove a few maps, so the other list will have downloadable ones, too
143
149
iso_maps [mission ].remove_rows ([0 , 1 ])
144
- ESASky .get_maps (iso_maps , download_dir = tmp_path )
150
+ result = ESASky .get_maps (iso_maps , download_dir = tmp_path )
145
151
assert len (os .listdir (file_path )) == len (all_maps [mission ]) - 2
152
+ for hdu_list in result [mission ]:
153
+ hdu_list .close ()
146
154
147
155
iso_maps2 = dict ({mission : all_maps [mission ][:2 ]})
148
- ESASky .get_maps (iso_maps2 , download_dir = tmp_path )
156
+ result = ESASky .get_maps (iso_maps2 , download_dir = tmp_path )
149
157
assert len (os .listdir (file_path )) == len (all_maps [mission ])
158
+ for hdu_list in result [mission ]:
159
+ hdu_list .close ()
150
160
151
161
def test_esasky_query_region_spectra (self ):
152
162
result = ESASky .query_region_spectra (position = "M51" , radius = "5 arcmin" )
@@ -164,9 +174,12 @@ def test_esasky_get_spectra(self, tmp_path, mission):
164
174
# - HST-IR, JWST-MID-IR and CHEOPS have no data
165
175
# - LAMOST does not support download
166
176
# - JWST-NEAR-IR returns a zip file with many fits files in it, unsupported
167
- ESASky .get_spectra (position = "M1" , missions = mission , download_dir = tmp_path )
177
+ result = ESASky .get_spectra (position = "M1" , missions = mission , download_dir = tmp_path )
178
+ assert Path (tmp_path , mission .upper ()).exists ()
168
179
169
- assert Path (tmp_path , mission ).exists ()
180
+ if mission != "Herschel" :
181
+ for hdu_list in result [mission .upper ()]:
182
+ hdu_list .close ()
170
183
171
184
def test_esasky_get_spectra_small (self , tmp_path ):
172
185
missions = ['HST-IR' ]
@@ -185,11 +198,15 @@ def test_esasky_get_spectra_from_table(self, tmp_path):
185
198
iso_spectra = ESASky .query_object_spectra (position = "M51" , missions = mission )
186
199
# Remove a few maps, so the other list will have downloadable ones, too
187
200
iso_spectra [mission ].remove_rows ([0 , 1 ])
188
- ESASky .get_spectra_from_table (query_table_list = iso_spectra , download_dir = tmp_path )
201
+ result = ESASky .get_spectra_from_table (query_table_list = iso_spectra , download_dir = tmp_path )
202
+ for hdu_list in result [mission ]:
203
+ hdu_list .close ()
189
204
assert len (os .listdir (file_path )) == len (all_spectra [mission ]) - 2
190
205
191
206
iso_spectra2 = dict ({mission : all_spectra [mission ][:2 ]})
192
- ESASky .get_spectra_from_table (query_table_list = iso_spectra2 , download_dir = tmp_path )
207
+ result = ESASky .get_spectra_from_table (query_table_list = iso_spectra2 , download_dir = tmp_path )
208
+ for hdu_list in result [mission ]:
209
+ hdu_list .close ()
193
210
assert len (os .listdir (file_path )) == len (all_spectra [mission ])
194
211
195
212
def test_query (self ):
0 commit comments