Skip to content

Commit 822ecf0

Browse files
authored
Merge pull request #3383 from bsipocz/MAINT_overflow_message_change
MAINT: adding workaround for pyvo Warning message changes
2 parents 6aa1cc8 + 66abfff commit 822ecf0

File tree

4 files changed

+18
-20
lines changed

4 files changed

+18
-20
lines changed

astroquery/alma/tests/test_alma_remote.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@
3737

3838
download_hostname = 'almascience.eso.org'
3939

40+
# The MAXREC related overflow message is different in pyvo 1.7+, remove workaround when we have it as a minimum
41+
overflow_message = r"Partial result set. Potential causes MAXREC|Result set limited by user- or server-supplied MAXREC"
42+
4043

4144
@pytest.fixture
4245
def alma(request):
@@ -56,14 +59,12 @@ def alma(request):
5659
@pytest.mark.remote_data
5760
class TestAlma:
5861
def test_public(self, alma):
59-
with pytest.warns(expected_warning=DALOverflowWarning,
60-
match="Partial result set. Potential causes MAXREC, async storage space, etc."):
62+
with pytest.warns(expected_warning=DALOverflowWarning, match=overflow_message):
6163
results = alma.query(payload=None, public=True, maxrec=100)
6264
assert len(results) == 100
6365
for row in results:
6466
assert row['data_rights'] == 'Public'
65-
with pytest.warns(expected_warning=DALOverflowWarning,
66-
match="Partial result set. Potential causes MAXREC, async storage space, etc."):
67+
with pytest.warns(expected_warning=DALOverflowWarning, match=overflow_message):
6768
results = alma.query(payload=None, public=False, maxrec=100)
6869
assert len(results) == 100
6970
for row in results:
@@ -105,8 +106,7 @@ def test_freq(self, alma):
105106
def test_bands(self, alma):
106107
payload = {'band_list': ['5', '7']}
107108
# Added maxrec here as downloading and reading the results take too long.
108-
with pytest.warns(expected_warning=DALOverflowWarning,
109-
match="Partial result set. Potential causes MAXREC, async storage space, etc."):
109+
with pytest.warns(expected_warning=DALOverflowWarning, match=overflow_message):
110110
result = alma.query(payload, maxrec=1000)
111111
assert len(result) > 0
112112
for row in result:
@@ -342,8 +342,7 @@ def test_misc(self, alma):
342342

343343
result = alma.query_object('M83', public=True, science=True)
344344
assert len(result) > 0
345-
with pytest.warns(expected_warning=DALOverflowWarning,
346-
match="Partial result set. Potential causes MAXREC, async storage space, etc."):
345+
with pytest.warns(expected_warning=DALOverflowWarning, match=overflow_message):
347346
result = alma.query(payload={'pi_name': 'Bally*'}, public=True,
348347
maxrec=10)
349348
assert result

astroquery/heasarc/tests/test_heasarc_remote.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
from astropy.utils.exceptions import AstropyDeprecationWarning
1212
from astroquery.exceptions import NoResultsWarning
1313
import pyvo
14+
from pyvo.dal.exceptions import DALOverflowWarning
1415

1516
from astroquery.heasarc import Heasarc
1617

@@ -56,6 +57,9 @@
5657
],
5758
]
5859

60+
# The MAXREC related overflow message is different in pyvo 1.7+, remove workaround when we have it as a minimum
61+
overflow_message = r"Partial result set. Potential causes MAXREC|Result set limited by user- or server-supplied MAXREC"
62+
5963

6064
@pytest.mark.remote_data
6165
class TestHeasarc:
@@ -158,13 +162,8 @@ def test_list_catalogs__keywords(self):
158162
reason="DALOverflowWarning is available only in pyvo>=1.4"
159163
)
160164
def test_tap__maxrec(self):
161-
from pyvo.dal.exceptions import DALOverflowWarning
162165
query = "SELECT TOP 10 ra,dec FROM xray"
163-
with pytest.warns(
164-
expected_warning=DALOverflowWarning,
165-
match=("Partial result set. Potential causes MAXREC, "
166-
"async storage space, etc."),
167-
):
166+
with pytest.warns(expected_warning=DALOverflowWarning, match=overflow_message):
168167
result = Heasarc.query_tap(query=query, maxrec=5)
169168
assert len(result) == 5
170169
assert result.to_table().colnames == ["ra", "dec"]

astroquery/ipac/irsa/tests/test_irsa_remote.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
from astropy.coordinates import SkyCoord
77
from astropy.utils.exceptions import AstropyDeprecationWarning
88

9-
from pyvo.dal.exceptions import DALOverflowWarning
10-
119
from astroquery.ipac.irsa import Irsa
1210

1311

@@ -114,9 +112,8 @@ def test_list_collections_filter(self):
114112

115113
def test_tap(self):
116114
query = "SELECT TOP 5 ra,dec FROM cosmos2015"
117-
with pytest.warns(expected_warning=DALOverflowWarning,
118-
match="Partial result set. Potential causes MAXREC, async storage space, etc."):
119-
result = Irsa.query_tap(query=query)
115+
116+
result = Irsa.query_tap(query=query)
120117
assert len(result) == 5
121118
assert result.to_table().colnames == ['ra', 'dec']
122119

astroquery/simbad/tests/test_simbad_remote.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@
2121
ICRS_COORDS_SgrB2 = SkyCoord(266.835*u.deg, -28.38528*u.deg, frame='icrs')
2222
multicoords = SkyCoord([ICRS_COORDS_SgrB2, ICRS_COORDS_SgrB2])
2323

24+
# The MAXREC related overflow message is different in pyvo 1.7+, remove workaround when we have it as a minimum
25+
overflow_message = r"Partial result set. Potential causes MAXREC|Result set limited by user- or server-supplied MAXREC"
26+
2427

2528
@pytest.mark.remote_data()
2629
class TestSimbad:
@@ -156,7 +159,7 @@ def test_query_tap(self):
156159
" c 3")
157160
assert expect == str(result)
158161
# Test query_tap raised errors
159-
with pytest.warns(DALOverflowWarning, match="Partial result set *"):
162+
with pytest.warns(DALOverflowWarning, match=overflow_message):
160163
truncated_result = Simbad.query_tap("SELECT * from basic", maxrec=2)
161164
assert len(truncated_result) == 2
162165
with pytest.raises(ValueError, match="The maximum number of records cannot exceed 2000000."):

0 commit comments

Comments
 (0)