Skip to content

Commit 119256a

Browse files
Add "validation" pytest marker (#2633)
1 parent 231a4b0 commit 119256a

7 files changed

Lines changed: 25 additions & 5 deletions

File tree

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ jobs:
127127
name: Unittest report ${{ matrix.os }}-${{ matrix.pixi-environment }}
128128
path: ${{ env.COVERAGE_REPORT }}
129129
flaky-unit-test:
130-
name: "Flaky unit tests: ${{ matrix.os }} | pixi run -e ${{ matrix.pixi-environment }} tests -m 'flaky'"
130+
name: "Flaky unit tests: ${{ matrix.os }} | pixi run -e ${{ matrix.pixi-environment }} tests-flaky"
131131
runs-on: ${{ matrix.os }}-latest
132132
needs: [cache-pixi-lock]
133133
permissions:
@@ -165,7 +165,7 @@ jobs:
165165
- name: Unit test
166166
id: unit-test
167167
run: |
168-
pixi run -e ${{ matrix.pixi-environment }} tests -m 'flaky' -v -s --cov=parcels --cov-report=xml --html="${COVERAGE_REPORT}" --self-contained-html
168+
pixi run -e ${{ matrix.pixi-environment }} tests-flaky -v -s --cov=parcels --cov-report=xml --html="${COVERAGE_REPORT}" --self-contained-html
169169
# explicitly save the cache so it gets updated, also do this even if it fails.
170170
- name: Save cached hypothesis directory
171171
id: save-hypothesis-cache

docs/development/maintainer.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
## Release checklist
2121

22+
- Run the validation test suite (`pixi run tests-validation`)
2223
- Go to GitHub, draft new release. Enter name of version and "create new tag" if it doesn't already exist. Click "Generate Release Notes". Currate release notes as needed. Look at a previous version release to match the format (title, header, section organisation etc.)
2324
- Go to [conda-forge/parcels-feedstock](https://github.com/conda-forge/parcels-feedstock), create a new issue (select the "Bot Commands" issue from the menu) with title `@conda-forge-admin, please update version`. This will prompt a build, otherwise there can be a delay in the build.
2425
- Approve PR and merge on green

pixi.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,9 @@ pytest-html = "*"
7979
pytest-cov = "*"
8080

8181
[feature.test.tasks]
82-
tests = { cmd = "pytest -m 'not flaky'", description = "Run the test suite." }
82+
tests = { cmd = "pytest", description = "Run the test suite." }
83+
tests-flaky = { cmd = "pytest -m 'flaky'", description = "Run flaky tests." }
84+
tests-validation = { cmd = "pytest -m 'validation'", description = "Run validation tests." }
8385
tests-notebooks = { cmd = "pytest --nbval-lax docs/user_guide/examples", description = "Run the user guide example notebooks as tests." }
8486

8587

pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,9 @@ testpaths = ["tests"]
5858
python_files = ["test_*.py", "example_*.py", "*tutorial*"]
5959
minversion = "7"
6060
markers = [ # can be skipped by doing `pytest -m "not slow"` etc.
61-
"flaky: flaky tests",
6261
"slow: slow tests",
62+
"validation: validation tests (skipped by default, run with `-m validation`)",
63+
"flaky: flaky tests (skipped by default, run with `-m flaky`)",
6364
"v4alpha: failing tests that should work for v4alpha",
6465
"v4future: failing tests that should work for a future release of v4",
6566
"v4remove: failing tests that should probably be removed later",

tests/conftest.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,19 @@
11
import pytest
22

3+
SKIP_BY_DEFAULT = {"validation", "flaky"}
4+
5+
6+
def pytest_collection_modifyitems(config, items):
7+
if not config.getoption("-m"):
8+
for item in items:
9+
print(item.keywords)
10+
skip_by_default = list(SKIP_BY_DEFAULT & set(item.keywords))
11+
if skip_by_default:
12+
skip_marker = skip_by_default[0] # get first marker in case of multiple
13+
item.add_marker(
14+
pytest.mark.skip(reason=f"{skip_marker} tests skipped by default, use `-m {skip_marker}` to run")
15+
)
16+
317

418
@pytest.fixture
519
def tmp_parquet(tmp_path):

tests/validation/__init__.py

Whitespace-only changes.
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@
3636
AdvectionRK4_3D,
3737
)
3838

39+
pytestmark = pytest.mark.validation
40+
3941
# Uniform translation parameters
4042
T1_1_U0 = 0.001
4143
T1_1_V0 = 0.0005
@@ -67,7 +69,7 @@
6769
)
6870
@pytest.mark.parametrize("integrator", [AdvectionEE, AdvectionRK4], ids=["EE", "RK4"])
6971
def test_uniform_translation_exact(dataset_fn, integrator):
70-
ds = dataset_fn(nx=20, U0=T1_1_U0, V0=T1_1_V0)
72+
ds = dataset_fn(nx=20, u0=T1_1_U0, v0=T1_1_V0)
7173
fieldset = parcels.FieldSet.from_ugrid_conventions(ds, mesh="flat")
7274

7375
pset = parcels.ParticleSet(fieldset, lon=[T1_1_LON0], lat=[T1_1_LAT0])

0 commit comments

Comments
 (0)