From 615f1c2fa206a618c3ef5989755916c891f489be Mon Sep 17 00:00:00 2001 From: Gui-FernandesBR Date: Mon, 16 Nov 2026 00:06:24 -0300 Subject: [PATCH 1/4] TST: keep the EnvironmentAnalysis tests in the slow run and skip without extras Parsing the EuRoC reanalysis takes most of their ~200 s, and cutting the files to the fixture's window only saved ~25%, so they go back under `slow`. Without windrose, ipywidgets, IPython or jsonpickle they now skip instead of failing, and the fixture pins Europe/Lisbon so test_values no longer depends on timezonefinder. Related to #1209 and #1176. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01XDW575d9C9zpS7Z1v2KXVq --- tests/fixtures/environment/environment_fixtures.py | 2 +- .../environment/test_environment_analysis.py | 11 +++++++++++ tests/unit/environment/test_environment_analysis.py | 10 ++++++++++ 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/tests/fixtures/environment/environment_fixtures.py b/tests/fixtures/environment/environment_fixtures.py index 2679e3ca3..088f56f85 100644 --- a/tests/fixtures/environment/environment_fixtures.py +++ b/tests/fixtures/environment/environment_fixtures.py @@ -116,7 +116,7 @@ def env_analysis(): end_hour=18, surface_data_file="./data/weather/EuroC_single_level_reanalysis_2002_2021.nc", pressure_level_data_file="./data/weather/EuroC_pressure_levels_reanalysis_2001-2021.nc", - timezone=None, + timezone="Europe/Lisbon", # what timezonefinder gives, without needing it unit_system="metric", forecast_date=None, forecast_args=None, diff --git a/tests/integration/environment/test_environment_analysis.py b/tests/integration/environment/test_environment_analysis.py index 6e3a76aef..958f82bed 100644 --- a/tests/integration/environment/test_environment_analysis.py +++ b/tests/integration/environment/test_environment_analysis.py @@ -3,12 +3,14 @@ from unittest.mock import patch import matplotlib as plt +import pytest from rocketpy import Environment plt.rcParams.update({"figure.max_open_warning": 0}) +@pytest.mark.slow @patch("matplotlib.pyplot.show") def test_all_info(mock_show, env_analysis): # pylint: disable=unused-argument """Test the EnvironmentAnalysis.all_info() method, which already invokes @@ -24,12 +26,16 @@ def test_all_info(mock_show, env_analysis): # pylint: disable=unused-argument ------- None """ + pytest.importorskip("windrose") + pytest.importorskip("ipywidgets") + pytest.importorskip("IPython") assert env_analysis.info() is None assert env_analysis.all_info() is None assert env_analysis.plots.info() is None os.remove("wind_rose.gif") # remove the files created by the method +@pytest.mark.slow @patch("matplotlib.pyplot.show") def test_exports(mock_show, env_analysis): # pylint: disable=unused-argument """Check the export methods of the EnvironmentAnalysis class. It @@ -42,6 +48,10 @@ def test_exports(mock_show, env_analysis): # pylint: disable=unused-argument env_analysis : EnvironmentAnalysis A simple object of the EnvironmentAnalysis class. """ + pytest.importorskip("windrose") + pytest.importorskip("ipywidgets") + pytest.importorskip("IPython") + pytest.importorskip("jsonpickle") assert env_analysis.export_mean_profiles() is None assert env_analysis.save("env_analysis_dict") is None @@ -56,6 +66,7 @@ def test_exports(mock_show, env_analysis): # pylint: disable=unused-argument os.remove("export_env_analysis.json") +@pytest.mark.slow @patch("matplotlib.pyplot.show") def test_create_environment_object(mock_show, env_analysis): # pylint: disable=unused-argument assert isinstance(env_analysis.create_environment_object(), Environment) diff --git a/tests/unit/environment/test_environment_analysis.py b/tests/unit/environment/test_environment_analysis.py index dda5df31b..cc5c22af6 100644 --- a/tests/unit/environment/test_environment_analysis.py +++ b/tests/unit/environment/test_environment_analysis.py @@ -48,6 +48,7 @@ def test_missing_timezonefinder_defaults_to_utc( assert analysis.end_date.tzinfo is not None +@pytest.mark.slow @patch("matplotlib.pyplot.show") def test_distribution_plots(mock_show, env_analysis): # pylint: disable=unused-argument """Tests the distribution plots method of the EnvironmentAnalysis class. It @@ -78,6 +79,7 @@ def test_distribution_plots(mock_show, env_analysis): # pylint: disable=unused- ) +@pytest.mark.slow @patch("matplotlib.pyplot.show") def test_average_plots(mock_show, env_analysis): # pylint: disable=unused-argument """Tests the average plots method of the EnvironmentAnalysis class. It @@ -94,6 +96,7 @@ def test_average_plots(mock_show, env_analysis): # pylint: disable=unused-argum ------- None """ + pytest.importorskip("windrose") # Check "average" plots assert env_analysis.plots.average_surface_temperature_evolution() is None assert env_analysis.plots.average_surface10m_wind_speed_evolution(False) is None @@ -103,6 +106,7 @@ def test_average_plots(mock_show, env_analysis): # pylint: disable=unused-argum assert env_analysis.plots.average_wind_rose_specific_hour(12) is None +@pytest.mark.slow @patch("matplotlib.pyplot.show") def test_profile_plots(mock_show, env_analysis): # pylint: disable=unused-argument """Check the profile plots method of the EnvironmentAnalysis class. It @@ -144,6 +148,7 @@ def test_profile_plots(mock_show, env_analysis): # pylint: disable=unused-argum ) +@pytest.mark.slow def test_values(env_analysis): """Check the numeric properties of the EnvironmentAnalysis class. It computes a few values and compares them to the expected values. Not all the values are @@ -167,6 +172,7 @@ def test_values(env_analysis): assert pytest.approx(env_analysis.std_pressure_at_30000ft, 1e-6) == 38.48947 +@pytest.mark.slow @patch("matplotlib.pyplot.show") def test_animation_plots(mock_show, env_analysis): # pylint: disable=unused-argument """Check the animation plots method of the EnvironmentAnalysis class. It @@ -181,6 +187,9 @@ def test_animation_plots(mock_show, env_analysis): # pylint: disable=unused-arg env_analysis : EnvironmentAnalysis A simple object of the EnvironmentAnalysis class. """ + pytest.importorskip("windrose") + pytest.importorskip("ipywidgets") + pytest.importorskip("IPython") # import dependencies widgets = import_optional_dependency("ipywidgets") HTML = import_optional_dependency("IPython.display").HTML @@ -197,6 +206,7 @@ def test_animation_plots(mock_show, env_analysis): # pylint: disable=unused-arg os.remove("wind_rose.gif") # remove the files created by the method +@pytest.mark.slow def test_pressure_level_wind_profile_uses_velocity_components(env_analysis): """Regression for PR #1041: the redundant per-level ``wind_heading`` and ``wind_direction`` functions were removed from the pressure-level data. From 3a57e5cbc1514b9457480ca35b065a08acce7ae0 Mon Sep 17 00:00:00 2001 From: Gui-FernandesBR Date: Mon, 16 Nov 2026 00:07:14 -0300 Subject: [PATCH 2/4] TST: label the Defiance reference metrics as a regression check Only the apogee is compared with the measured flight. The max speed and impact point are RocketPy's own output, so they are now named as a regression check, and the max acceleration check is dropped because it pinned a 1 us solver spike at burnout. Related to #1209. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01XDW575d9C9zpS7Z1v2KXVq --- tests/acceptance/test_defiance_rocket.py | 31 +++++++++++------------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/tests/acceptance/test_defiance_rocket.py b/tests/acceptance/test_defiance_rocket.py index 1afe5143d..e10dabc09 100644 --- a/tests/acceptance/test_defiance_rocket.py +++ b/tests/acceptance/test_defiance_rocket.py @@ -1,4 +1,4 @@ -"""Acceptance test for the 2024 Defiance example flight.""" +"""Defiance 2024 flight: apogee against the measured flight, the rest as a regression.""" import pytest @@ -9,12 +9,12 @@ MEASURED_APOGEE_AGL = 9308.32 MAX_RELATIVE_APOGEE_ERROR = 0.01 -REFERENCE_MAX_SPEED = 444.24 -REFERENCE_MAX_ACCELERATION = 10400.76 -REFERENCE_IMPACT_X = 1550.23 -REFERENCE_IMPACT_Y = 104.80 -REFERENCE_METRIC_RELATIVE_TOLERANCE = 0.01 -REFERENCE_IMPACT_ABSOLUTE_TOLERANCE = 3.0 +# RocketPy's own output, not flight data: they only catch unintended changes. +REGRESSION_MAX_SPEED = 444.24 +REGRESSION_IMPACT_X = 1550.23 +REGRESSION_IMPACT_Y = 104.80 +REGRESSION_RELATIVE_TOLERANCE = 0.01 +REGRESSION_IMPACT_ABSOLUTE_TOLERANCE = 3.0 def _build_defiance_flight(): @@ -122,21 +122,18 @@ def test_defiance_rocket_apogee_matches_measured_flight(defiance_flight): ) -def test_defiance_rocket_matches_reference_flight_metrics(defiance_flight): - """Guard the deterministic example's peak and impact metrics.""" - tolerance = {"rel": REFERENCE_METRIC_RELATIVE_TOLERANCE} +def test_defiance_rocket_regression_flight_metrics(defiance_flight): + """Guard the example's max speed and impact point against unintended changes.""" + tolerance = {"rel": REGRESSION_RELATIVE_TOLERANCE} impact_tolerance = { **tolerance, - "abs": REFERENCE_IMPACT_ABSOLUTE_TOLERANCE, + "abs": REGRESSION_IMPACT_ABSOLUTE_TOLERANCE, } - assert defiance_flight.max_speed == pytest.approx(REFERENCE_MAX_SPEED, **tolerance) - assert defiance_flight.max_acceleration == pytest.approx( - REFERENCE_MAX_ACCELERATION, **tolerance - ) + assert defiance_flight.max_speed == pytest.approx(REGRESSION_MAX_SPEED, **tolerance) assert defiance_flight.x_impact == pytest.approx( - REFERENCE_IMPACT_X, **impact_tolerance + REGRESSION_IMPACT_X, **impact_tolerance ) assert defiance_flight.y_impact == pytest.approx( - REFERENCE_IMPACT_Y, **impact_tolerance + REGRESSION_IMPACT_Y, **impact_tolerance ) From f1c1c202379a8f3a70d631740999a7a3fda36e8d Mon Sep 17 00:00:00 2001 From: Gui-FernandesBR Date: Mon, 16 Nov 2026 00:09:20 -0300 Subject: [PATCH 3/4] MNT: list folium in requirements-optional.txt The maps extra in pyproject.toml already has it, but make install and the development setup guide install from this file, so plot_trajectory_map did not work in that environment. Related to #1209. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01XDW575d9C9zpS7Z1v2KXVq --- requirements-optional.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/requirements-optional.txt b/requirements-optional.txt index d1d95b2e6..e47096ff2 100644 --- a/requirements-optional.txt +++ b/requirements-optional.txt @@ -9,4 +9,5 @@ statsmodels prettytable contextily>=1.0.0; python_version < '3.14' pyvista>=0.45 -imageio-ffmpeg>=0.5 \ No newline at end of file +imageio-ffmpeg>=0.5 +folium>=0.14 From 51bcedbef0ceb45bcdb3970ffb48a936aafcd4cd Mon Sep 17 00:00:00 2001 From: Gui-FernandesBR Date: Mon, 16 Nov 2026 00:09:21 -0300 Subject: [PATCH 4/4] MNT: run the changelog script tests in the Tests workflow The changelog workflow runs only after a merge, so a broken update_changelog.py was found only on develop. Its test file needs no network or extra packages. Related to #1209. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01XDW575d9C9zpS7Z1v2KXVq --- .github/workflows/test_pytest.yaml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/test_pytest.yaml b/.github/workflows/test_pytest.yaml index e5b944317..b02aa5f03 100644 --- a/.github/workflows/test_pytest.yaml +++ b/.github/workflows/test_pytest.yaml @@ -76,6 +76,10 @@ jobs: - name: Run Unit Tests run: pytest tests/unit --cov=rocketpy + # The changelog workflow only runs after a merge, so its script is tested here. + - name: Test the changelog script + run: pytest .github/scripts/test_update_changelog.py + - name: Run Documentation Tests run: | pip install numpy --upgrade