Skip to content

Commit f91c955

Browse files
authored
Merge pull request #2346 from bsipocz/MNT_fix_eso_gaia_remote
MNT: fixing more remote tests
2 parents b6de267 + 9270204 commit f91c955

File tree

2 files changed

+32
-15
lines changed

2 files changed

+32
-15
lines changed

astroquery/eso/tests/test_eso_remote.py

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
import pytest
44
import tempfile
55
import shutil
6-
from ...exceptions import LoginError
6+
import warnings
7+
8+
from astroquery.exceptions import LoginError, NoResultsWarning
79

810
from ...eso import Eso
911

@@ -93,8 +95,9 @@ def test_empty_return(self):
9395
surveys = eso.list_surveys(cache=False)
9496
assert len(surveys) > 0
9597
# Avoid SESAME
96-
result_s = eso.query_surveys(surveys[0], coord1=202.469575,
97-
coord2=47.195258, cache=False)
98+
with pytest.warns(NoResultsWarning):
99+
result_s = eso.query_surveys(surveys[0], coord1=202.469575,
100+
coord2=47.195258, cache=False)
98101

99102
assert result_s is None
100103

@@ -163,7 +166,7 @@ def test_apex_retrieval(self):
163166
tbl = eso.query_apex_quicklooks(prog_id='095.F-9802')
164167
tblb = eso.query_apex_quicklooks('095.F-9802')
165168

166-
assert len(tbl) == 4
169+
assert len(tbl) == 5
167170
assert set(tbl['Release Date']) == {'2015-07-17', '2015-07-18',
168171
'2015-09-15', '2015-09-18'}
169172

@@ -174,20 +177,35 @@ def test_each_instrument_SgrAstar(self, temp_dir):
174177
eso.cache_location = temp_dir
175178

176179
instruments = eso.list_instruments(cache=False)
177-
for instrument in instruments:
178-
result_i = eso.query_instrument(instrument, coord1=266.41681662,
179-
coord2=-29.00782497, cache=False)
180180

181+
for instrument in instruments:
182+
with pytest.warns(None) as record:
183+
result_i = eso.query_instrument(instrument, coord1=266.41681662,
184+
coord2=-29.00782497, cache=False)
185+
# Sometimes there are ResourceWarnings, we ignore those for this test
186+
if len(record) > 0 and NoResultsWarning in {record[i].category for i in range(len(record))}:
187+
assert result_i is None
188+
else:
189+
assert len(result_i) > 0
190+
191+
@pytest.mark.filterwarnings("ignore::ResourceWarning")
181192
def test_each_survey_SgrAstar(self, temp_dir):
182193
eso = Eso()
183194
eso.cache_location = temp_dir
184195

185196
surveys = eso.list_surveys(cache=False)
186197
for survey in surveys:
187-
result_s = eso.query_surveys(survey, coord1=266.41681662,
188-
coord2=-29.00782497,
189-
box='01 00 00',
190-
cache=False)
198+
with pytest.warns(None) as record:
199+
result_s = eso.query_surveys(survey, coord1=266.41681662,
200+
coord2=-29.00782497,
201+
box='01 00 00',
202+
cache=False)
203+
# Sometimes there are ResourceWarnings, we ignore those for this test
204+
if len(record) > 0 and NoResultsWarning in {record[i].category for i in range(len(record))}:
205+
assert result_s is None
206+
else:
207+
print([record[i].message for i in range(len(record))])
208+
assert len(result_s) > 0
191209

192210
@pytest.mark.skipif("SKIP_SLOW")
193211
@pytest.mark.parametrize('cache', (False, True))

docs/gaia/gaia.rst

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ radius argument.
170170
INFO: Query finished. [astroquery.utils.tap.core]
171171
>>> r = j.get_results()
172172
>>> r.pprint()
173-
solution_id designation ... dist
173+
solution_id DESIGNATION ... dist
174174
...
175175
------------------- ---------------------------- ... ---------------------
176176
1635721458409799680 Gaia DR2 6636090334814214528 ... 0.0026034636994048854
@@ -184,7 +184,6 @@ radius argument.
184184
1635721458409799680 Gaia DR2 6636089583198817664 ... 0.008338509690874027
185185
1635721458409799680 Gaia DR2 6636089578899968384 ... 0.008406677772258921
186186
... ... ... ...
187-
188187
1635721458409799680 Gaia DR2 6636089510180765312 ... 0.01943176697471851
189188
1635721458409799680 Gaia DR2 6636066871411763712 ... 0.019464719601172412
190189
1635721458409799680 Gaia DR2 6636089514475519232 ... 0.019467068628703368
@@ -418,8 +417,8 @@ Query without saving results in a file:
418417
INFO: Query finished. [astroquery.utils.tap.core]
419418
>>> r = job.get_results()
420419
>>> print(r)
421-
designation ra dec
422-
deg deg
420+
DESIGNATION ra dec
421+
deg deg
423422
---------------------- ------------------ --------------------
424423
Gaia DR2 4295806720 44.996153684159594 0.005615806210679649
425424
Gaia DR2 34361129088 45.004316164207644 0.021045032689712983

0 commit comments

Comments
 (0)