Test and CI#

We use pytest for testing and github actions for CI. - Unit tests are mandatory for new methods and workflows and integration tests are highly recommended for various - All tests should be contained in the tests directory in functions named test_*. - We use SonarQube to monitor the coverage of the tests and aim for high (>90%) coverage. This is work in progress. - Checkout this comprehensive guide to pytest for more info and tips.

Running the tests#

HydroMT’s tests live in the tests folder and generally match the main package layout. Test should be run from the tests folder.

To run the entire suite and the code coverage report:

$ cd tests
$ python -m pytest --verbose --cov=hydromt --cov-report term-missing

A single test file:

$ python -m pytest --verbose test_rio.py

A single test:

$ python -m pytest --verbose test_rio.py::test_object

Alternatively, you can also run tests using the pixi install described in the developer installation guide.

Run all tests:

$ pixi run pytest

Run tests in a specific file:

$ pixi run pytest tests/test_rio.py

Run a specific test function:

$ pixi run pytest tests/test_rio.py::test_object