File astropy-pr18335-jplephem.patch of Package python-astropy
From e1b7efbee34a6393bcfbc313ce81d4b5a06c6113 Mon Sep 17 00:00:00 2001
From: "P. L. Lim" <2090236+pllim@users.noreply.github.com>
Date: Mon, 23 Jun 2025 22:39:44 -0700
Subject: [PATCH] Backport PR #18331 on branch v7.1.x (TST: simplify `jplephem`
test case for newer versions)
TST: simplify `jplephem` test case for newer versions
---
astropy/coordinates/tests/test_solar_system.py | 10 ++++++----
pyproject.toml | 1 +
2 files changed, 7 insertions(+), 4 deletions(-)
diff --git a/astropy/coordinates/tests/test_solar_system.py b/astropy/coordinates/tests/test_solar_system.py
index 06acc1756c94..781e5c590357 100644
--- a/astropy/coordinates/tests/test_solar_system.py
+++ b/astropy/coordinates/tests/test_solar_system.py
@@ -24,6 +24,7 @@
from astropy.tests.helper import CI, assert_quantity_allclose
from astropy.time import Time
from astropy.units import allclose as quantity_allclose
+from astropy.utils import minversion
from astropy.utils.compat.optional_deps import HAS_JPLEPHEM, HAS_SKYFIELD
from astropy.utils.data import download_file, get_pkg_data_filename
@@ -395,12 +396,13 @@ def test_ephemeris_wrong_input(ephemeris, expected_error):
get_body("earth", Time("1960-01-12 00:00"), ephemeris=ephemeris)
+# jplephem<2.23 leaves the file open (a ResourceWarning is emitted)
+@pytest.mark.filterwarnings(
+ "error" if minversion("jplephem", "2.23") else "ignore", category=ResourceWarning
+)
@pytest.mark.skipif(not HAS_JPLEPHEM, reason="requires jplephem")
def test_ephemeris_local_file_not_ephemeris():
- # NOTE: This test currently leaves the file open (ResourceWarning).
- # To fix this issue, an upstream fix is required in jplephem
- # package.
- with pytest.warns(ResourceWarning), pytest.raises(ValueError, match="^file starts"):
+ with pytest.raises(ValueError, match="^file starts"):
get_body("earth", Time("1960-01-12 00:00"), ephemeris=__file__)
diff --git a/pyproject.toml b/pyproject.toml
index 745a6bf823f5..c25cf2310cfa 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -53,6 +53,7 @@ dependencies = [
# Recommended run-time dependencies to enable a lot of functionality within Astropy.
recommended = [
"scipy>=1.9.2",
+ "scipy<1.16 ; platform_system=='Windows'", # temp, https://github.com/astropy/astropy/issues/18333
"matplotlib>=3.6.0",
]
# Optional IPython-related behavior is in many places in Astropy. IPython is a complex