From 9ed684552ca1c35c056a47a5414de8e7a4ee89fd Mon Sep 17 00:00:00 2001 From: jerome de leon Date: Thu, 9 Apr 2026 11:13:22 +0900 Subject: [PATCH] Catch HTTP errors from MAST outages in network tests The existing tests only caught RemoteServiceError, but MAST outages also raise requests.exceptions.HTTPError (HTTP 500). Widen the catch to include HTTPError, ConnectionError, and TimeoutError so CI xfails gracefully on remote service issues instead of failing the build. Co-Authored-By: Claude Opus 4.6 --- tests/test_tql.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/tests/test_tql.py b/tests/test_tql.py index c7a2adc..412a766 100755 --- a/tests/test_tql.py +++ b/tests/test_tql.py @@ -7,8 +7,12 @@ from quicklook.tql import TessQuickLook import lightkurve as lk import astropy.units as u +import requests from astroquery.exceptions import RemoteServiceError +# Network errors that indicate MAST/remote service issues, not code bugs. +_NETWORK_ERRORS = (RemoteServiceError, requests.exceptions.HTTPError, ConnectionError, TimeoutError) + @pytest.fixture def planet_inputs(): @@ -69,8 +73,8 @@ def test_tql_planet(planet_inputs): # Check that TLS was run assert hasattr(ql, "tls_results") assert ql.tls_results.period > 0 - except RemoteServiceError as e: - # CI-specific soft failure + except _NETWORK_ERRORS as e: + # CI-specific soft failure — MAST outages are not code bugs if os.getenv("CI", "false") == "true": pytest.xfail(f"Network failure (not a bug): {e}") else: @@ -100,8 +104,8 @@ def test_tql_eb(eb_inputs): # Check that TLS was run assert hasattr(ql, "tls_results") assert ql.tls_results.period > 0 - except RemoteServiceError as e: - # CI-specific soft failure + except _NETWORK_ERRORS as e: + # CI-specific soft failure — MAST outages are not code bugs if os.getenv("CI", "false") == "true": pytest.xfail(f"Network failure (not a bug): {e}") else: @@ -122,8 +126,8 @@ def test_tql_variable_star(variable_star_inputs): assert ql.sector == variable_star_inputs["sector"] assert ql.flux_type == variable_star_inputs["flux_type"].lower() assert ql.pipeline == variable_star_inputs["pipeline"].lower() - except RemoteServiceError as e: - # CI-specific soft failure + except _NETWORK_ERRORS as e: + # CI-specific soft failure — MAST outages are not code bugs if os.getenv("CI", "false") == "true": pytest.xfail(f"Network failure (not a bug): {e}") else: