From c529bfdb32ad3ddcdd04e33aacc867442c4efb06 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Brigitta=20Sip=C5=91cz?= Date: Fri, 14 Jun 2024 14:02:40 -0700 Subject: [PATCH 1/2] TST: skipping test when dependency is missing --- astroquery/alma/tests/test_alma_remote.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/astroquery/alma/tests/test_alma_remote.py b/astroquery/alma/tests/test_alma_remote.py index db8362a57e..b9258afcaf 100644 --- a/astroquery/alma/tests/test_alma_remote.py +++ b/astroquery/alma/tests/test_alma_remote.py @@ -16,6 +16,13 @@ from astroquery.exceptions import CorruptDataWarning from astroquery.alma import Alma, get_enhanced_table +try: + import regions + + HAS_REGIONS = True +except ImportError: + HAS_REGIONS = False + # ALMA tests involving staging take too long, leading to travis timeouts # TODO: make this a configuration item SKIP_SLOW = True @@ -62,11 +69,10 @@ def test_public(self, alma): for row in results: assert row['data_rights'] == 'Proprietary' + @pytest.mark.skipif(not HAS_REGIONS, reason="regions is required") @pytest.mark.filterwarnings( "ignore::astropy.utils.exceptions.AstropyUserWarning") def test_s_region(self, alma): - pytest.importorskip('regions') - import regions # to silence checkstyle alma.help_tap() result = alma.query_tap("select top 3 s_region from ivoa.obscore") enhanced_result = get_enhanced_table(result) @@ -75,6 +81,7 @@ def test_s_region(self, alma): regions.PolygonSkyRegion, regions.CompoundSkyRegion)) + @pytest.mark.skipif(not HAS_REGIONS, reason="regions is required") @pytest.mark.filterwarnings( "ignore::astropy.utils.exceptions.AstropyUserWarning") def test_SgrAstar(self, tmp_path, alma): From a682a6a7d6e6a354e7afe76c497c9f91a5dafa87 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Brigitta=20Sip=C5=91cz?= Date: Fri, 14 Jun 2024 14:07:58 -0700 Subject: [PATCH 2/2] MAINT: raise exception for missing dependency --- astroquery/alma/core.py | 1 + 1 file changed, 1 insertion(+) diff --git a/astroquery/alma/core.py b/astroquery/alma/core.py index 947d24d53b..52adff39e0 100644 --- a/astroquery/alma/core.py +++ b/astroquery/alma/core.py @@ -218,6 +218,7 @@ def get_enhanced_table(result): print( "Could not import astropy-regions, which is a requirement for get_enhanced_table function in alma." "Please refer to http://astropy-regions.readthedocs.io/en/latest/installation.html for how to install it.") + raise def _parse_stcs_string(input): csys = 'icrs'