From 5d4343fd25ca43ae4dcf8145535356690be04da2 Mon Sep 17 00:00:00 2001 From: Ting-Hong Shieh <32212900+ting-hong-shieh@users.noreply.github.com> Date: Mon, 17 Aug 2026 00:04:17 +0800 Subject: [PATCH] TST: run the EnvironmentAnalysis tests in the default suite Nine of the ten EnvironmentAnalysis tests carried @pytest.mark.slow, so test_pytest.yaml never ran them and the subsystem measured 7.0%, 39.7% and 19.4% in the run that gates every pull request. They were not slow because of the work they do. The env_analysis fixture reads two committed files under data/weather/, touches no network, and was declared at function scope, so the nine tests each rebuilt it and twenty years of hourly reanalysis data was parsed nine times. Roughly 212 of the 247 seconds the two files took were that repeated setup. Scope the fixture to the session and drop the nine marks. No test rebinds its attributes; test_exports already loads into a copy.deepcopy rather than into the fixture. Non-slow coverage goes from 84.2757% to 89.6674%, +945 statements, for about 74 seconds across the five steps. --- tests/fixtures/environment/environment_fixtures.py | 2 +- tests/integration/environment/test_environment_analysis.py | 4 ---- tests/unit/environment/test_environment_analysis.py | 6 ------ 3 files changed, 1 insertion(+), 11 deletions(-) diff --git a/tests/fixtures/environment/environment_fixtures.py b/tests/fixtures/environment/environment_fixtures.py index 91b185a35..2679e3ca3 100644 --- a/tests/fixtures/environment/environment_fixtures.py +++ b/tests/fixtures/environment/environment_fixtures.py @@ -99,7 +99,7 @@ def example_euroc_env(example_date_naive): return euroc_env -@pytest.fixture +@pytest.fixture(scope="session") def env_analysis(): """Environment Analysis class with hardcoded parameters diff --git a/tests/integration/environment/test_environment_analysis.py b/tests/integration/environment/test_environment_analysis.py index 2b12a2057..6e3a76aef 100644 --- a/tests/integration/environment/test_environment_analysis.py +++ b/tests/integration/environment/test_environment_analysis.py @@ -3,14 +3,12 @@ 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 @@ -32,7 +30,6 @@ def test_all_info(mock_show, env_analysis): # pylint: disable=unused-argument 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 @@ -59,7 +56,6 @@ 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 a9f9a945e..dda5df31b 100644 --- a/tests/unit/environment/test_environment_analysis.py +++ b/tests/unit/environment/test_environment_analysis.py @@ -48,7 +48,6 @@ 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 @@ -79,7 +78,6 @@ 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 @@ -105,7 +103,6 @@ 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 @@ -147,7 +144,6 @@ 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 @@ -171,7 +167,6 @@ 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 @@ -202,7 +197,6 @@ 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.