From c12ecb3c1fde13b5e73736b733e64756e348caea Mon Sep 17 00:00:00 2001 From: Srija Yadav Date: Sat, 28 Mar 2026 20:37:29 -0400 Subject: [PATCH] Add pytest unit/integration markers and test-running docs --- CONTRIBUTING.md | 26 +++++++++++++++++++++++++- pytest.ini | 8 +++----- tests/test_direct_power_method.py | 2 ++ tests/test_genetic.py | 2 ++ tests/test_maripower_tanker.py | 2 ++ tests/test_utils.py | 2 ++ tests/test_weather.py | 2 ++ 7 files changed, 38 insertions(+), 6 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 70c396ab..94e4bd6b 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,3 +1,27 @@ Contributions are always welcome. Before creating [Pull Requests](https://github.com/52North/WeatherRoutingTool/pulls) or commenting [Issues](https://github.com/52North/WeatherRoutingTool/issues) please carefully read the [Contributing](https://52north.github.io/WeatherRoutingTool/source/guidelines/contribution_guidelines.html) section in our documentation. -Please do not ask if you can work on an issue. Just re-read our documentation and remember that contributions are welcome! Also be aware that we do not assign issues to contributors we have not worked with yet. If this applies to you please do not ask to be assigned. \ No newline at end of file +Please do not ask if you can work on an issue. Just re-read our documentation and remember that contributions are welcome! Also be aware that we do not assign issues to contributors we have not worked with yet. If this applies to you please do not ask to be assigned. + +## Running tests + +The test suite uses pytest markers to separate fast unit tests from broader integration tests and optional/manual tests. + +### Unit tests +```bash +./.venv/bin/pytest -m "unit" -q +``` + +### Integration tests +```bash +./.venv/bin/pytest -m "integration and not manual and not maripower" -q +``` + +### Manual tests +```bash +./.venv/bin/pytest -m "manual" -q +``` + +### Maripower tests +```bash +./.venv/bin/pytest -m "maripower" -q +``` diff --git a/pytest.ini b/pytest.ini index f8b76279..8acf383a 100644 --- a/pytest.ini +++ b/pytest.ini @@ -1,11 +1,9 @@ [pytest] -markers = +markers = + unit: fast tests for isolated functions/classes + integration: tests using configs, datasets, or multiple components genetic: tests for genetic algorithm maripower: tests that need maripower support manual: tests that produce figures as output addopts = -ra --tb=short --strict-markers - - - - diff --git a/tests/test_direct_power_method.py b/tests/test_direct_power_method.py index 7d366ee7..ddeda5b3 100644 --- a/tests/test_direct_power_method.py +++ b/tests/test_direct_power_method.py @@ -22,6 +22,8 @@ except ModuleNotFoundError: pass # maripower installation is optional +pytestmark = pytest.mark.integration + class TestDPM: ''' diff --git a/tests/test_genetic.py b/tests/test_genetic.py index 7042c075..3bfe3f5d 100644 --- a/tests/test_genetic.py +++ b/tests/test_genetic.py @@ -22,6 +22,8 @@ from WeatherRoutingTool.ship.ship_config import ShipConfig from WeatherRoutingTool.utils.maps import Map +pytestmark = pytest.mark.integration + def test_isofuelpatcher_singleton(): dirname = os.path.dirname(__file__) diff --git a/tests/test_maripower_tanker.py b/tests/test_maripower_tanker.py index 3e36fed9..97eb02fe 100644 --- a/tests/test_maripower_tanker.py +++ b/tests/test_maripower_tanker.py @@ -22,6 +22,8 @@ except ModuleNotFoundError: pass # maripower installation is optional +pytestmark = pytest.mark.integration + @pytest.mark.skip(reason="maripower needs update of requirements.") # @pytest.mark.skipif(not have_maripower, reason="maripower is not installed") diff --git a/tests/test_utils.py b/tests/test_utils.py index dacf5e54..b813281a 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -8,6 +8,8 @@ import WeatherRoutingTool.algorithms.genetic.utils as gen_utils from WeatherRoutingTool.utils.maps import Map +pytestmark = pytest.mark.unit + def test_get_angle_bins_2greater360(): min_alpha = 380 * u.degree diff --git a/tests/test_weather.py b/tests/test_weather.py index ed3dc346..f19ca2b8 100644 --- a/tests/test_weather.py +++ b/tests/test_weather.py @@ -2,6 +2,8 @@ from WeatherRoutingTool.weather import WeatherCond +pytestmark = pytest.mark.unit + @pytest.mark.parametrize("u,v,theta_res", [(-1, -1, 45), (1, -1, 315), (1, 1, 225), (-1, 1, 135)]) def test_theta_from_uv(u, v, theta_res):