Skip to content

Commit c529bfd

Browse files
committed
TST: skipping test when dependency is missing
1 parent 2f2a643 commit c529bfd

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

astroquery/alma/tests/test_alma_remote.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,13 @@
1616
from astroquery.exceptions import CorruptDataWarning
1717
from astroquery.alma import Alma, get_enhanced_table
1818

19+
try:
20+
import regions
21+
22+
HAS_REGIONS = True
23+
except ImportError:
24+
HAS_REGIONS = False
25+
1926
# ALMA tests involving staging take too long, leading to travis timeouts
2027
# TODO: make this a configuration item
2128
SKIP_SLOW = True
@@ -62,11 +69,10 @@ def test_public(self, alma):
6269
for row in results:
6370
assert row['data_rights'] == 'Proprietary'
6471

72+
@pytest.mark.skipif(not HAS_REGIONS, reason="regions is required")
6573
@pytest.mark.filterwarnings(
6674
"ignore::astropy.utils.exceptions.AstropyUserWarning")
6775
def test_s_region(self, alma):
68-
pytest.importorskip('regions')
69-
import regions # to silence checkstyle
7076
alma.help_tap()
7177
result = alma.query_tap("select top 3 s_region from ivoa.obscore")
7278
enhanced_result = get_enhanced_table(result)
@@ -75,6 +81,7 @@ def test_s_region(self, alma):
7581
regions.PolygonSkyRegion,
7682
regions.CompoundSkyRegion))
7783

84+
@pytest.mark.skipif(not HAS_REGIONS, reason="regions is required")
7885
@pytest.mark.filterwarnings(
7986
"ignore::astropy.utils.exceptions.AstropyUserWarning")
8087
def test_SgrAstar(self, tmp_path, alma):

0 commit comments

Comments
 (0)