Skip to content

Commit cd8c963

Browse files
authored
Merge pull request #2605 from bsipocz/MAINT_ignore_warning_take2
MAINT: remote test follow-up for older bs4 versions
2 parents c97f304 + 377af29 commit cd8c963

File tree

1 file changed

+27
-3
lines changed

1 file changed

+27
-3
lines changed

astroquery/cadc/tests/test_cadctap_remote.py

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,19 @@
1313
from astropy.coordinates import SkyCoord
1414
from astropy.io import fits
1515
from astropy import units as u
16+
import warnings
1617

1718
from astroquery.cadc import Cadc
1819
from astroquery.utils.commons import parse_coordinates, FileContainer
1920

2021
from pyvo.auth import authsession
2122

23+
try:
24+
# workaround for https://github.com/astropy/astroquery/issues/2523 to support bs4<4.11
25+
from bs4.builder import XMLParsedAsHTMLWarning
26+
except ImportError:
27+
XMLParsedAsHTMLWarning = None
28+
2229
# Skip the very slow tests to avoid timeout errors
2330
skip_slow = True
2431

@@ -51,7 +58,13 @@ def test_query_region(self):
5158
# do some manipulation of the results. Below it's filtering out based
5259
# on target name but other manipulations are possible.
5360
assert len(result) > 0
54-
urls = cadc.get_data_urls(result[result['target_name'] == 'Nr3491_1'])
61+
62+
# Remove this filter when https://github.com/astropy/astroquery/issues/2523 is fixed
63+
with warnings.catch_warnings():
64+
if XMLParsedAsHTMLWarning:
65+
warnings.filterwarnings("ignore", category=XMLParsedAsHTMLWarning)
66+
urls = cadc.get_data_urls(result[result['target_name'] == 'Nr3491_1'])
67+
5568
assert len(urls) > 0
5669
# urls are a subset of the results that match target_name==Nr3491_1
5770
assert len(result) >= len(urls)
@@ -185,7 +198,13 @@ def test_get_images(self):
185198
cadc = Cadc()
186199
coords = '08h45m07.5s +54d18m00s'
187200
radius = 0.005*u.deg
188-
images = cadc.get_images(coords, radius, collection='CFHT')
201+
202+
# Remove this filter when https://github.com/astropy/astroquery/issues/2523 is fixed
203+
with warnings.catch_warnings():
204+
if XMLParsedAsHTMLWarning:
205+
warnings.filterwarnings("ignore", category=XMLParsedAsHTMLWarning)
206+
images = cadc.get_images(coords, radius, collection='CFHT')
207+
189208
assert images is not None
190209

191210
for image in images:
@@ -228,7 +247,12 @@ def test_get_images_async(self):
228247
cadc = Cadc()
229248
coords = '01h45m07.5s +23d18m00s'
230249
radius = '0.05 deg'
231-
readable_objs = cadc.get_images_async(coords, radius, collection="CFHT")
250+
251+
# Remove this filter when https://github.com/astropy/astroquery/issues/2523 is fixed
252+
with warnings.catch_warnings():
253+
if XMLParsedAsHTMLWarning:
254+
warnings.filterwarnings("ignore", category=XMLParsedAsHTMLWarning)
255+
readable_objs = cadc.get_images_async(coords, radius, collection="CFHT")
232256
assert readable_objs is not None
233257
for obj in readable_objs:
234258
assert isinstance(obj, FileContainer)

0 commit comments

Comments
 (0)