Testing
- This project supports two testing workflows:
Running tests directly with a single Python interpreter
Running the full multi-version and quality-check matrix using
tox
Single-Python Workflow
Run serial unit tests:
pytest tests/
MPI tests are marked with the pytest marker @pytest.mark.mpi() and require the
pytest-mpi plugin. Only tests decorated with this marker are executed when running MPI tests.
For example, an MPI test function can be defined like this:
import pytest
@pytest.mark.mpi()
def test_parallel_function():
...
To run MPI tests with 8 processes:
mpiexec -n 8 pytest tests/ --only-mpi
Notes:
The
--only-mpiflag is implemented viapytest-mpi.Serial tests (without the marker) are skipped when using
--only-mpi.
Note
On some shared systems, Open MPI may refuse to launch MPI jobs if the requested number of
processes exceeds available CPU cores. In these cases, the --oversubscribe flag is required.
The tox workflow handles this automatically, so you usually only need to worry about it
when running mpiexec manually.
Tox Workflow (Recommended)
To run the full test matrix:
tox
- This runs:
Unit and MPI tests across all supported Python versions
Linting, formatting, type checking, and coverage
See Tox-Based Testing for details on the test matrix and available environments.
Note
Running tox requires Python 3.10-3.12 for complete testing. See
Managing Python Versions for installation instructions.