Skip to content

Commit 7c7e488

Browse files
committed
TST: Disable flaky SAMP server tests in CI
because they fail a lot with timeout expired errors nowadays. TST: Move CI and IS_CRON to tests helper module so they can be shared across the test suite.
1 parent 23bf960 commit 7c7e488

9 files changed

Lines changed: 18 additions & 15 deletions

File tree

‎astropy/coordinates/tests/test_intermediate_transformations.py‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
"""Accuracy tests for GCRS coordinate transformations, primarily to/from AltAz.
33
44
"""
5-
import os
65
import warnings
76
from importlib import metadata
87

@@ -41,15 +40,14 @@
4140
)
4241
from astropy.coordinates.builtin_frames.utils import get_jd12
4342
from astropy.coordinates.solar_system import get_body
43+
from astropy.tests.helper import CI
4444
from astropy.tests.helper import assert_quantity_allclose as assert_allclose
4545
from astropy.time import Time
4646
from astropy.units import allclose
4747
from astropy.utils import iers
4848
from astropy.utils.compat.optional_deps import HAS_JPLEPHEM
4949
from astropy.utils.exceptions import AstropyWarning
5050

51-
CI = os.environ.get("CI", False) == "true"
52-
5351

5452
def test_icrs_cirs():
5553
"""

‎astropy/coordinates/tests/test_solar_system.py‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import os
21
from urllib.error import HTTPError
32

43
import numpy as np
@@ -23,7 +22,7 @@
2322
get_moon,
2423
solar_system_ephemeris,
2524
)
26-
from astropy.tests.helper import assert_quantity_allclose
25+
from astropy.tests.helper import CI, assert_quantity_allclose
2726
from astropy.time import Time
2827
from astropy.units import allclose as quantity_allclose
2928
from astropy.utils.compat.optional_deps import HAS_JPLEPHEM, HAS_SKYFIELD
@@ -45,7 +44,7 @@ def skyfield_ephemeris(tmp_path_factory):
4544
planets = load("de421.bsp")
4645
ts = load.timescale()
4746
except OSError as e:
48-
if os.environ.get("CI", False) and "timed out" in str(e):
47+
if CI and "timed out" in str(e):
4948
pytest.xfail("Timed out in CI")
5049
else:
5150
raise

‎astropy/io/ascii/tests/test_c_reader.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,13 @@
2828
FastTab,
2929
)
3030
from astropy.table import MaskedColumn, Table
31+
from astropy.tests.helper import CI
3132
from astropy.utils.data import get_pkg_data_filename
3233
from astropy.utils.exceptions import AstropyWarning
3334

3435
from .common import assert_almost_equal, assert_equal, assert_true
3536

3637
StringIO = lambda x: BytesIO(x.encode("ascii"))
37-
CI = os.environ.get("CI", False)
3838

3939

4040
def assert_table_equal(t1, t2, check_meta=False, rtol=1.0e-15, atol=1.0e-300):

‎astropy/samp/tests/test_standard_profile.py‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from astropy.samp.errors import SAMPProxyError
66
from astropy.samp.hub import SAMPHubServer
77
from astropy.samp.integrated_client import SAMPIntegratedClient
8+
from astropy.tests.helper import CI
89

910
from .test_helpers import TEST_REPLY, Receiver, assert_output, random_params
1011

@@ -13,6 +14,7 @@ def setup_module(module):
1314
conf.use_internet = False
1415

1516

17+
@pytest.mark.skipif(CI, reason="flaky in CI")
1618
class TestStandardProfile:
1719
@property
1820
def hub_init_kwargs(self):

‎astropy/samp/tests/test_web_profile.py‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
from astropy.samp import SAMPHubServer, SAMPIntegratedClient, conf
1313
from astropy.samp.web_profile import CLIENT_ACCESS_POLICY, CROSS_DOMAIN
14+
from astropy.tests.helper import CI
1415
from astropy.utils.data import get_readable_fileobj
1516

1617
from .test_standard_profile import TestStandardProfile as BaseTestStandardProfile
@@ -24,6 +25,7 @@ def setup_module(module):
2425
conf.use_internet = False
2526

2627

28+
@pytest.mark.skipif(CI, reason="flaky in CI")
2729
class TestWebProfile(BaseTestStandardProfile):
2830
@pytest.fixture(autouse=True)
2931
def setup_method(self, tmp_path):

‎astropy/tests/helper.py‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@
2525

2626
PYTEST_LT_8_0 = not minversion(pytest, "8.0.dev")
2727

28+
# https://docs.github.com/en/actions/learn-github-actions/variables#default-environment-variables
29+
CI = os.environ.get("CI", "false") == "true"
30+
IS_CRON = os.environ.get("IS_CRON", "false") == "true"
31+
2832

2933
def _save_coverage(cov, result, rootdir, testing_path):
3034
"""

‎astropy/utils/iers/tests/test_iers.py‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,12 @@
1717
from astropy import units as u
1818
from astropy.config import set_temp_cache
1919
from astropy.table import QTable
20-
from astropy.tests.helper import assert_quantity_allclose
20+
from astropy.tests.helper import CI, assert_quantity_allclose
2121
from astropy.time import Time, TimeDelta
2222
from astropy.utils.data import get_pkg_data_filename
2323
from astropy.utils.exceptions import AstropyDeprecationWarning
2424
from astropy.utils.iers import iers
2525

26-
CI = os.environ.get("CI", False)
27-
2826
FILE_NOT_FOUND_ERROR = getattr(__builtins__, "FileNotFoundError", OSError)
2927

3028
try:
@@ -413,7 +411,7 @@ def test_IERS_B_parameters_loading_into_IERS_Auto():
413411

414412

415413
# Issue with FTP, rework test into previous one when it's fixed
416-
@pytest.mark.skipif("CI", reason="Flaky on CI")
414+
@pytest.mark.skipif(CI, reason="Flaky on CI")
417415
@pytest.mark.remote_data
418416
def test_iers_a_dl():
419417
iersa_tab = iers.IERS_A.open(iers.IERS_A_URL, cache=False)

‎astropy/utils/tests/test_data.py‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
import astropy.utils.data
2929
from astropy import units as _u # u is taken
3030
from astropy.config import paths
31-
from astropy.tests.helper import PYTEST_LT_8_0
31+
from astropy.tests.helper import CI, IS_CRON, PYTEST_LT_8_0
3232
from astropy.utils.data import (
3333
CacheDamaged,
3434
CacheMissingWarning,
@@ -60,7 +60,6 @@
6060
)
6161
from astropy.utils.exceptions import AstropyWarning
6262

63-
CI = os.environ.get("CI", "false") == "true"
6463
TESTURL = "http://www.astropy.org"
6564
TESTURL2 = "http://www.astropy.org/about.html"
6665
TESTURL_SSL = "https://www.astropy.org"
@@ -2191,7 +2190,7 @@ def no_rename(path, mode=None):
21912190

21922191

21932192
@pytest.mark.skipif(
2194-
CI and os.environ.get("IS_CRON", "false") == "false",
2193+
CI and not IS_CRON,
21952194
reason="Flaky/too much external traffic for regular CI",
21962195
)
21972196
@pytest.mark.remote_data

‎astropy/utils/tests/test_misc.py‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import pytest
1111

1212
from astropy.io import fits
13+
from astropy.tests.helper import CI
1314
from astropy.utils import data, misc
1415
from astropy.utils.exceptions import AstropyDeprecationWarning
1516

@@ -34,7 +35,7 @@ def test_api_lookup():
3435
strurl = misc.find_api_page("astropy.utils.misc", "dev", False, timeout=5)
3536
objurl = misc.find_api_page(misc, "dev", False, timeout=5)
3637
except (urllib.error.URLError, TimeoutError):
37-
if os.environ.get("CI", False):
38+
if CI:
3839
pytest.xfail("Timed out in CI")
3940
else:
4041
raise

0 commit comments

Comments
 (0)