From 1303e3ee3ef734d7cbcb3c972826a089992b058b Mon Sep 17 00:00:00 2001 From: "r.jaepel" Date: Mon, 11 Nov 2024 16:36:49 +0100 Subject: [PATCH] Remove custom cadet_root from tests. Add `local` tag to tests that require multiple different CADET installations which is not feasible on the CI and remove those tests from the CI. --- .github/workflows/pipeline.yml | 2 +- pyproject.toml | 4 ++++ tests/test_dll.py | 5 ++--- tests/test_install_path_settings.py | 9 +++++++-- tests/test_meta_class_install_path.py | 6 +++++- 5 files changed, 19 insertions(+), 7 deletions(-) diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.yml index c19d50a..14033df 100644 --- a/.github/workflows/pipeline.yml +++ b/.github/workflows/pipeline.yml @@ -63,4 +63,4 @@ jobs: run: | pip install .[testing] mamba install cadet -c conda-forge - pytest tests --rootdir=tests -m "not slow" + pytest tests --rootdir=tests -m "not slow and not local" diff --git a/pyproject.toml b/pyproject.toml index 199b2ca..1a1e629 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -51,3 +51,7 @@ line-length = 88 [tool.pytest.ini_options] testpaths = ["tests"] +markers = [ + "slow: marks tests as slow (deselect with '-m \"not slow\"')", + "local: marks tests as only useful on local installs (deselect with '-m \"not local\"')", +] \ No newline at end of file diff --git a/tests/test_dll.py b/tests/test_dll.py index b34156c..fddc2bf 100644 --- a/tests/test_dll.py +++ b/tests/test_dll.py @@ -7,9 +7,8 @@ # %% Utility methods -# TODO: Remove once #14 is merged -# cadet_root = Path('/home/jo/code/CADET/install/capi/') -cadet_root = Path(r'C:\Users\ronal\Documents\CADET\out\install\aRELEASE') +# Use this to specify custom cadet_roots if you require it. +cadet_root = None def setup_model( cadet_root, diff --git a/tests/test_install_path_settings.py b/tests/test_install_path_settings.py index 5f7ecc0..99db92a 100644 --- a/tests/test_install_path_settings.py +++ b/tests/test_install_path_settings.py @@ -6,8 +6,11 @@ from cadet import Cadet +""" These tests require two distinct CADET installations to compare between and should not run in the CI""" + + # Full path to cadet.dll or cadet.so, that is different from the system/conda cadet -full_path_dll = Path(r"C:\Users\ronal\Documents\CADET\out\install\aRELEASE\bin\cadet.dll") +full_path_dll = Path("path/to/cadet") install_path_conda = Cadet.autodetect_cadet() @@ -19,7 +22,7 @@ def test_autodetection(): assert sim.cadet_cli_path.parent.parent == install_path_conda assert sim.cadet_runner.cadet_path.suffix not in [".dll", ".so"] - +@pytest.mark.local def test_install_path(): sim = Cadet(install_path=full_path_dll, use_dll=True) assert sim.cadet_dll_path == full_path_dll @@ -40,6 +43,7 @@ def test_install_path(): assert sim.cadet_runner.cadet_path.suffix in [".dll", ".so"] +@pytest.mark.local def test_dll_runner_attrs(): cadet = Cadet(full_path_dll.parent.parent) cadet_runner = cadet._cadet_dll_runner @@ -50,6 +54,7 @@ def test_dll_runner_attrs(): assert isinstance(cadet_runner.cadet_path, str | os.PathLike) +@pytest.mark.local def test_cli_runner_attrs(): cadet = Cadet(full_path_dll.parent.parent) cadet_runner = cadet._cadet_cli_runner diff --git a/tests/test_meta_class_install_path.py b/tests/test_meta_class_install_path.py index 9959747..e46e40e 100644 --- a/tests/test_meta_class_install_path.py +++ b/tests/test_meta_class_install_path.py @@ -1,14 +1,18 @@ from pathlib import Path +import pytest from cadet import Cadet +""" These tests require two distinct CADET installations to compare between and should not run in the CI""" + # Full path to cadet.dll or cadet.so, that is different from the system/conda cadet -full_path_dll = Path(r"C:\Users\ronal\Documents\CADET\out\install\aRELEASE\bin\cadet.dll") +full_path_dll = Path("path/to/cadet") install_path_conda = Cadet.autodetect_cadet() +@pytest.mark.local def test_meta_class(): Cadet.cadet_path = full_path_dll assert Cadet.use_dll