Skip to content

Commit 3b1d8ec

Browse files
committed
Only monkeypatch for affected astropy version
1 parent 8d61379 commit 3b1d8ec

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

astroquery/utils/commons.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,12 @@ def FK4CoordGenerator(*args, **kwargs):
5252
'suppress_vo_warnings',
5353
'validate_email',
5454
'ASTROPY_LT_4_0',
55-
'ASTROPY_LT_4_1']
55+
'ASTROPY_LT_4_1',
56+
'ASTROPY_LT_4_3']
5657

5758
ASTROPY_LT_4_0 = not minversion('astropy', '4.0')
5859
ASTROPY_LT_4_1 = not minversion('astropy', '4.1')
60+
ASTROPY_LT_4_3 = not minversion('astropy', '4.3')
5961

6062

6163
def send_request(url, data, timeout, request_type='POST', headers={},

astroquery/utils/tests/test_utils.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -410,8 +410,11 @@ def patch_getreadablefileobj(request):
410410
# Monkeypatch hack: ALWAYS treat as a URL
411411
_is_url = aud._is_url
412412
aud._is_url = lambda x: True
413-
_try_url_open = aud._try_url_open
414-
aud._try_url_open = lambda x, **kwargs: MockRemote(x, **kwargs)
413+
414+
if not commons.ASTROPY_LT_4_3:
415+
_try_url_open = aud._try_url_open
416+
aud._try_url_open = lambda x, **kwargs: MockRemote(x, **kwargs)
417+
415418
_urlopen = urllib.request.urlopen
416419
_urlopener = urllib.request.build_opener
417420
_urlrequest = urllib.request.Request
@@ -459,7 +462,10 @@ def monkey_urlrequest(x, *args, **kwargs):
459462

460463
def closing():
461464
aud._is_url = _is_url
462-
aud._try_url_open = _try_url_open
465+
466+
if not commons.ASTROPY_LT_4_3:
467+
aud._try_url_open = _try_url_open
468+
463469
urllib.request.urlopen = _urlopen
464470
aud.urllib.request.urlopen = _urlopen
465471
urllib.request.build_opener = _urlopener

0 commit comments

Comments
 (0)