diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index abbbb781..a19c7521 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -78,6 +78,13 @@ by [CI pipelines](#CI). Before pushing your changes to the remote we recommend to execute `pytest` locally in order to detect mistakes early on and to avoid failing pipelines. +Slow tests (> 5s) are marked by the `@pytest.mark.slow` decorator. +To run all tests except the slow ones, use: + +```shell +pytest -m "not slow" +``` + ## Notebooks We use notebooks both as documentation (copied over to `docs/examples`) and as diff --git a/pyproject.toml b/pyproject.toml index 39fe25a9..e449db52 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -7,3 +7,8 @@ build-backend = "setuptools.build_meta" [tool.setuptools_scm] # See configuration details in https://github.com/pypa/setuptools_scm version_scheme = "no-guess-dev" + +[tool.pytest.ini_options] +markers = [ + "slow: marks tests as slow (> 5s)", +] diff --git a/tests/operators/test_deeponet.py b/tests/operators/test_deeponet.py index 9ce7c1cc..7db57cc4 100644 --- a/tests/operators/test_deeponet.py +++ b/tests/operators/test_deeponet.py @@ -1,5 +1,6 @@ import torch import matplotlib.pyplot as plt +import pytest from continuity.plotting import plot, plot_evaluation from torch.utils.data import DataLoader @@ -40,6 +41,7 @@ def test_output_shape(): assert v_other_pred.shape == v_other.shape +@pytest.mark.slow def test_deeponet(): # Parameters num_sensors = 16 diff --git a/tests/operators/test_neuraloperator.py b/tests/operators/test_neuraloperator.py index 715efe4e..0b077cc0 100644 --- a/tests/operators/test_neuraloperator.py +++ b/tests/operators/test_neuraloperator.py @@ -1,3 +1,4 @@ +import pytest import torch import matplotlib.pyplot as plt from continuity.data import Sine @@ -9,6 +10,7 @@ torch.manual_seed(0) +@pytest.mark.slow def test_neuraloperator(): # Parameters num_sensors = 16 diff --git a/tests/test_optuna.py b/tests/test_optuna.py index ea602e9e..ef2c313e 100644 --- a/tests/test_optuna.py +++ b/tests/test_optuna.py @@ -1,3 +1,4 @@ +import pytest import torch from torch.utils.data import DataLoader from continuity.benchmarks.sine import SineBenchmark @@ -10,6 +11,7 @@ torch.manual_seed(0) +@pytest.mark.slow def test_optuna(): def objective(trial): trunk_width = trial.suggest_int("trunk_width", 4, 16)