|
13 | 13 | from astropy.coordinates import SkyCoord
|
14 | 14 | from astropy.io import fits
|
15 | 15 | from astropy import units as u
|
| 16 | +import warnings |
16 | 17 |
|
17 | 18 | from astroquery.cadc import Cadc
|
18 | 19 | from astroquery.utils.commons import parse_coordinates, FileContainer
|
19 | 20 |
|
20 | 21 | from pyvo.auth import authsession
|
21 | 22 |
|
| 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 | + |
22 | 29 | # Skip the very slow tests to avoid timeout errors
|
23 | 30 | skip_slow = True
|
24 | 31 |
|
@@ -51,7 +58,13 @@ def test_query_region(self):
|
51 | 58 | # do some manipulation of the results. Below it's filtering out based
|
52 | 59 | # on target name but other manipulations are possible.
|
53 | 60 | 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 | + |
55 | 68 | assert len(urls) > 0
|
56 | 69 | # urls are a subset of the results that match target_name==Nr3491_1
|
57 | 70 | assert len(result) >= len(urls)
|
@@ -185,7 +198,13 @@ def test_get_images(self):
|
185 | 198 | cadc = Cadc()
|
186 | 199 | coords = '08h45m07.5s +54d18m00s'
|
187 | 200 | 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 | + |
189 | 208 | assert images is not None
|
190 | 209 |
|
191 | 210 | for image in images:
|
@@ -228,7 +247,12 @@ def test_get_images_async(self):
|
228 | 247 | cadc = Cadc()
|
229 | 248 | coords = '01h45m07.5s +23d18m00s'
|
230 | 249 | 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") |
232 | 256 | assert readable_objs is not None
|
233 | 257 | for obj in readable_objs:
|
234 | 258 | assert isinstance(obj, FileContainer)
|
|
0 commit comments