From c98b5a580f6f4f70ff758f5d74e2232a69b1811e Mon Sep 17 00:00:00 2001 From: Jean Connelly Date: Wed, 9 Mar 2022 19:08:31 -0500 Subject: [PATCH 1/2] Use has_internet to skip planet tests requiring network --- chandra_aca/tests/test_planets.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/chandra_aca/tests/test_planets.py b/chandra_aca/tests/test_planets.py index d6c71bb..9e517a1 100644 --- a/chandra_aca/tests/test_planets.py +++ b/chandra_aca/tests/test_planets.py @@ -5,6 +5,7 @@ import astropy.units as u import pytest +from testr.test_helper import has_internet from cxotime import CxoTime from chandra_aca.planets import (get_planet_chandra, get_planet_barycentric, get_planet_chandra_horizons, get_planet_eci, @@ -13,6 +14,10 @@ from agasc import sphere_dist +HAS_INTERNET = has_internet() + + +@pytest.mark.skipif('not HAS_INTERNET', reason='Requires network access') def test_planet_positions(): # Test basic functionality and include regression values (not an independent # functional test) @@ -105,6 +110,7 @@ def test_planet_positions_array(): assert np.all(sphere_dist(ra, dec, ra2, dec2) * 3600 < 1.0) +@pytest.mark.skipif('not HAS_INTERNET', reason='Requires network access') def test_get_chandra_planet_horizons(): dat = get_planet_chandra_horizons('jupiter', '2020:001', '2020:002', n_times=11) exp = [' time ra dec rate_ra rate_dec mag ' @@ -139,6 +145,7 @@ def test_get_chandra_planet_horizons(): assert dat.pformat_all() == exp +@pytest.mark.skipif('not HAS_INTERNET', reason='Requires network access') @pytest.mark.parametrize('obs_pos,exp_sep', [('chandra-horizons', 0.0), ('chandra', 0.74), ('earth', 23.02)]) @@ -150,6 +157,7 @@ def test_get_planet_ang_separation_scalar(obs_pos, exp_sep): assert np.isclose(sep * 3600, exp_sep, atol=1e-2, rtol=0) +@pytest.mark.skipif('not HAS_INTERNET', reason='Requires network access') @pytest.mark.parametrize('obs_pos,exp_sep', [('chandra-horizons', [0.0, 33.98]), ('chandra', [0.74, 33.25]), ('earth', [23.02, 47.07])]) From 3e8d417e5fd62722669f5508ad5233046bbf0751 Mon Sep 17 00:00:00 2001 From: Jean Connelly Date: Wed, 16 Mar 2022 13:25:41 -0400 Subject: [PATCH 2/2] De-string the skipif conditional --- chandra_aca/tests/test_planets.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/chandra_aca/tests/test_planets.py b/chandra_aca/tests/test_planets.py index 9e517a1..f004dad 100644 --- a/chandra_aca/tests/test_planets.py +++ b/chandra_aca/tests/test_planets.py @@ -17,7 +17,7 @@ HAS_INTERNET = has_internet() -@pytest.mark.skipif('not HAS_INTERNET', reason='Requires network access') +@pytest.mark.skipif(not HAS_INTERNET, reason='Requires network access') def test_planet_positions(): # Test basic functionality and include regression values (not an independent # functional test) @@ -110,7 +110,7 @@ def test_planet_positions_array(): assert np.all(sphere_dist(ra, dec, ra2, dec2) * 3600 < 1.0) -@pytest.mark.skipif('not HAS_INTERNET', reason='Requires network access') +@pytest.mark.skipif(not HAS_INTERNET, reason='Requires network access') def test_get_chandra_planet_horizons(): dat = get_planet_chandra_horizons('jupiter', '2020:001', '2020:002', n_times=11) exp = [' time ra dec rate_ra rate_dec mag ' @@ -145,7 +145,7 @@ def test_get_chandra_planet_horizons(): assert dat.pformat_all() == exp -@pytest.mark.skipif('not HAS_INTERNET', reason='Requires network access') +@pytest.mark.skipif(not HAS_INTERNET, reason='Requires network access') @pytest.mark.parametrize('obs_pos,exp_sep', [('chandra-horizons', 0.0), ('chandra', 0.74), ('earth', 23.02)]) @@ -157,7 +157,7 @@ def test_get_planet_ang_separation_scalar(obs_pos, exp_sep): assert np.isclose(sep * 3600, exp_sep, atol=1e-2, rtol=0) -@pytest.mark.skipif('not HAS_INTERNET', reason='Requires network access') +@pytest.mark.skipif(not HAS_INTERNET, reason='Requires network access') @pytest.mark.parametrize('obs_pos,exp_sep', [('chandra-horizons', [0.0, 33.98]), ('chandra', [0.74, 33.25]), ('earth', [23.02, 47.07])])