How-to: Run Tests and Check Coverage¶
Problem¶
You want to run tests and check coverage across all optional dependency sets.
Quick Start¶
Single Environment (uv)¶
For basic development:
cd rgpycrumbs
uv sync --extra test
uv run pytest tests/ -m pure
Full Coverage (pixi)¶
pixi manages multiple environments with different optional deps:
pixi run cov
This runs:
Environment |
Deps |
Test marker |
Covers |
|---|---|---|---|
test |
numpy, scipy, ase, click |
pure, eon |
CLI, parsers, basetypes, interpolation |
surfaces |
|
surfaces |
Surface models, kernels, gradient-enhanced GP |
fragments |
|
fragments, ira, align |
Geometry analysis, IRA alignment, fragments |
eonmlflow |
|
eon |
MLflow logging of eOn runs and configs |
ptm |
|
ptm |
Polyhedral template matching, |
Each env writes COVERAGE_FILE=.coverage.<env>, then cov combines them all.
A failing test in any environment stops cov with the pytest exit status.
Individual Environments¶
pixi run -e test test-base # base tests
pixi run -e surfaces test-surfaces # jax surface models
pixi run -e fragments test-fragments # IRA + geometry
pixi run -e eonmlflow test-eonmlflow # eon + mlflow
pixi run -e ptm test-ptm # ovito structure analysis
The ptm environment installs the Python module of the Open Visualization Tool (OVITO) from https://conda.ovito.org.
The version constraint in pixi.toml is >=3.16.0, <4, and pixi.lock pins 3.17.2 for Python 3.13.
The comment above ovito in pixi.toml gives the basis for that constraint.
The ovito package on conda-forge is a retired OVITO Basic desktop build without the Python module.
With that package, every ptm test skips.
How It Works¶
digraph coverage_flow {
fontname="Jost"; fontsize=12;
node [fontname="Jost", fontsize=12, shape=box, style=filled, fillcolor=white];
edge [fontname="Jost", fontsize=11];
clean [label="cov-clean\nremove .coverage.*", fillcolor="#F1DB4B"];
test [label="test-base\n(numpy, scipy, ase)"];
surfaces [label="test-surfaces\n(+ jax)"];
fragments [label="test-fragments\n(+ IRA, tblite)"];
eonmlflow [label="test-eonmlflow\n(+ eon, mlflow)"];
ptm [label="test-ptm\n(+ ovito)"];
combine [label="coverage combine\none .coverage.<env> per env", fillcolor="#FF655D", fontcolor=white];
report [label="coverage report", fillcolor="#004D40", fontcolor=white];
clean -> test -> combine;
clean -> surfaces -> combine;
clean -> fragments -> combine;
clean -> eonmlflow -> combine;
clean -> ptm -> combine;
combine -> report;
}
Quality Guidelines¶
New modules must have tests in the same PR
Plot functions: at least smoke tests
Parsers: synthetic input + output schema validation
Pixi-only or heavyweight deps (IRA, tblite, pyvista, ovito): tested in their dedicated envs, not mocked