Skip to content

Commit 2876c7e

Browse files
committed
skipping tests when mocpy is not available
1 parent 418f656 commit 2876c7e

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

astroquery/cds/tests/test_mocserver.py

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,15 @@
1111

1212
try:
1313
from mocpy import MOC
14+
HAS_MOCPY = True
1415
except ImportError:
15-
pass
16+
HAS_MOCPY = False
1617

1718
try:
1819
from regions import CircleSkyRegion, PolygonSkyRegion
20+
HAS_REGIONS = True
1921
except ImportError:
20-
pass
22+
HAS_REGIONS = False
2123

2224
from ..core import cds
2325
from ...utils.testing_tools import MockResponse
@@ -72,8 +74,8 @@ def data_path(filename):
7274
"""
7375

7476

75-
@pytest.mark.skipif('regions' not in sys.modules,
76-
reason="requires astropy-regions")
77+
@pytest.mark.skipif('not HAS_REGIONS')
78+
@pytest.mark.skipif('not HAS_MOCPY')
7779
@pytest.mark.parametrize('datafile',
7880
['PROPERTIES_SEARCH', 'HIPS_FROM_SAADA_AND_ALASKY'])
7981
def test_request_results(patch_get, datafile):
@@ -97,8 +99,8 @@ def test_request_results(patch_get, datafile):
9799
"""
98100

99101

100-
@pytest.mark.skipif('regions' not in sys.modules,
101-
reason="requires astropy-regions")
102+
@pytest.mark.skipif('not HAS_REGIONS')
103+
@pytest.mark.skipif('not HAS_MOCPY')
102104
@pytest.mark.parametrize('RA, DEC, RADIUS',
103105
[(10.8, 6.5, 0.5),
104106
(25.6, -23.2, 1.1),
@@ -117,8 +119,8 @@ def test_cone_search_spatial_request(RA, DEC, RADIUS):
117119
(request_payload['SR'] == str(RADIUS))
118120

119121

120-
@pytest.mark.skipif('regions' not in sys.modules,
121-
reason="requires astropy-regions")
122+
@pytest.mark.skipif('not HAS_REGIONS')
123+
@pytest.mark.skipif('not HAS_MOCPY')
122124
@pytest.mark.parametrize('poly, poly_payload',
123125
[(polygon1, 'Polygon 57.376 24.053 56.391 24.622 56.025 24.049 56.616 24.291'),
124126
(polygon2, 'Polygon 58.376 24.053 53.391 25.622 56.025 22.049 54.616 27.291')])
@@ -132,8 +134,8 @@ def test_polygon_spatial_request(poly, poly_payload):
132134
assert request_payload['stc'] == poly_payload
133135

134136

135-
@pytest.mark.skipif('regions' not in sys.modules,
136-
reason="requires astropy-regions")
137+
@pytest.mark.skipif('not HAS_REGIONS')
138+
@pytest.mark.skipif('not HAS_MOCPY')
137139
@pytest.mark.parametrize('intersect',
138140
['encloses', 'overlaps', 'covers'])
139141
def test_intersect_param(intersect):

0 commit comments

Comments
 (0)