Skip to content

Commit

Permalink
Merge pull request #41 from aai-institute/feature/pytest-speed-mark
Browse files Browse the repository at this point in the history
Feature: Pytest Slow Mark
  • Loading branch information
samuelburbulla committed Feb 15, 2024
2 parents 9723d65 + 18a1f2c commit 13281fa
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 0 deletions.
7 changes: 7 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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)",
]
2 changes: 2 additions & 0 deletions tests/operators/test_deeponet.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions tests/operators/test_neuraloperator.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import pytest
import torch
import matplotlib.pyplot as plt
from continuity.data import Sine
Expand All @@ -9,6 +10,7 @@
torch.manual_seed(0)


@pytest.mark.slow
def test_neuraloperator():
# Parameters
num_sensors = 16
Expand Down
2 changes: 2 additions & 0 deletions tests/test_optuna.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import pytest
import torch
from torch.utils.data import DataLoader
from continuity.benchmarks.sine import SineBenchmark
Expand All @@ -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)
Expand Down

0 comments on commit 13281fa

Please sign in to comment.