Skip to content

Commit 5cfeb20

Browse files
committed
chore(tests): add large model test marker to pytest.ini
1 parent 0b4e70d commit 5cfeb20

3 files changed

Lines changed: 33 additions & 109 deletions

File tree

DEVELOPER.md

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ This document describes how to set up a development environment to modify, build
3030
- [Building](#building)
3131
- [Testing](#testing)
3232
- [Configuring a test environment](#configuring-a-test-environment)
33-
- [Testing](#testing-1)
3433
- [Building development binaries](#building-development-binaries)
3534
- [Rebuilding and installing release binaries](#rebuilding-and-installing-release-binaries)
3635
- [Updating `flopy` plugins](#updating-flopy-plugins)
@@ -41,6 +40,7 @@ This document describes how to set up a development environment to modify, build
4140
- [Running Tests](#running-tests)
4241
- [Selecting tests with markers](#selecting-tests-with-markers)
4342
- [External model tests](#external-model-tests)
43+
- [Writing tests](#writing-tests)
4444

4545
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
4646

@@ -237,7 +237,6 @@ MODFLOW 6 tests are driven with [`pytest`](https://docs.pytest.org/en/7.1.x/), w
237237

238238
A few tasks must be completed before running tests:
239239

240-
## Testing
241240
- build local MODFLOW 6 development version
242241
- rebuild the last MODFLOW 6 release
243242
- install additional executables
@@ -362,6 +361,8 @@ pytest -v -n auto
362361
Markers can be used to select subsets of tests. Markers provided in `pytest.ini` include:
363362

364363
- `slow`: tests that take longer than a few seconds to complete
364+
- `repo`: tests that require external model repositories
365+
- `large`: tests using large models (from the `modflow6-examples` and `modflow6-largetestmodels` repos)
365366
- `regression`: tests comparing results from multiple versions
366367

367368
Markers can be used with the `-m <marker>` option, and can be applied in boolean combinations with `and`, `or` and `not`. For instance, to run fast tests in parallel, excluding regression tests:
@@ -386,18 +387,39 @@ Tests using models from external repositories can be selected with the `repo` ma
386387
pytest -v -n auto -m "repo"
387388
```
388389

389-
The test scripts can also be run independently:
390+
The `large` marker is a subset of the `repo` marker. To test models excluded from commit-triggered CI and only run on GitHub Actions nightly:
391+
392+
```shell
393+
pytest -v -n auto -m "large"
394+
```
395+
396+
Test scripts for external model repositories can also be run independently:
390397

391398
```shell
392-
# Run MODFLOW 6 test models
399+
# MODFLOW 6 test models
393400
pytest -v -n auto test_z01_testmodels_mf6.py
394401

395-
# Run MODFLOW 5 to 6 conversion test models
402+
# MODFLOW 5 to 6 conversion test models
396403
pytest -v -n auto test_z02_testmodels_mf5to6.py
397404

398-
# Run example models
405+
# models from modflow6-examples repo
399406
pytest -v -n auto test_z03_examples.py
400407

401-
# Run large test models
408+
# models from modflow6-largetestmodels repo
402409
pytest -v -n auto test_z03_largetestmodels.py
403410
```
411+
412+
Tests load external models from fixtures provided by `modflow-devtools`. External model tests can be selected by model or simulation name, or by packages used. See the [`modflow-devtools` documentation](https://modflow-devtools.readthedocs.io/en/latest/md/fixtures.html#filtering) for usage examples. Note that filtering options only apply to tests using external models, and will not filter tests defining models in code &mdash; for that, the `pytest` built-in `-k` option may be used.
413+
414+
#### Writing tests
415+
416+
Tests should ideally follow a few conventions for easier maintenance:
417+
418+
- Use temporary directory fixtures. Tests which write to disk should use `pytest`'s built-in `tmp_path` fixtures or one of the [keepable temporary directory fixtures from `modflow-devtools`](https://modflow-devtools.readthedocs.io/en/latest/md/fixtures.html#keepable-temporary-directories). This prevents tests from polluting one another's state.
419+
420+
- Use markers for convenient (de-)selection:
421+
- `@pytest.mark.slow` if the test doesn't complete in a few seconds (this preserves the ability to quickly [`--smoke` test](https://modflow-devtools.readthedocs.io/en/latest/md/markers.html#smoke-testing)
422+
- `@pytest.mark.repo` if the test relies on external model repositories
423+
- `@pytest.mark.regression` if the test compares results from different versions
424+
425+
The test suite must pass before code can be merged, so be sure it passes locally before opening a PR.

autotest/pytest.ini

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ markers =
1010
developmode: tests that should only run with IDEVELOPMODE = 1
1111
gwf: tests for groundwater flow models
1212
gwt: tests for groundwater transport models
13-
ats: tests for adaptive time step utility plugin
14-
aux: tests for auxiliary variables plugin
15-
lak: tests for flow lake plugin
16-
maw: tests for multi-aquifer well plugin
13+
ats: tests for adaptive time step package
14+
aux: tests for auxiliary variables
15+
lak: tests for lake package
16+
maw: tests for multi-aquifer well package

autotest/targets.py

Lines changed: 0 additions & 98 deletions
This file was deleted.

0 commit comments

Comments
 (0)