Testing

After the development install, run affected tests first, then the suite and coverage:

pytest tests/path/to/affected_test.py
pytest tests
pytest tests --cov dascore --cov-report term-missing

The suite is parallel-safe; pytest tests -n logical --dist loadfile is usually fastest locally. CI requires 100% combined coverage across operating systems, although one platform may report lines covered elsewhere. Useful pytest flags include -s, -x, and --pdb.

Run docstrings and executable .qmd examples with:

pytest dascore --doctest-modules
python scripts/generate_doc_code_tests.py
pytest tests/test_autogenerated_doccode

The generated directory is gitignored; do not commit it.

Differential checks

When rewriting behavior, compare exact results against another git ref:

python scripts/differential_check.py --ref dev

The script fingerprints data, coordinates, dtype, units, and metadata for calls in get_calls and MATRIX_CALLS. Add the rewritten function to the appropriate list; unlisted functions are not checked. Differences are exact, not approximate.

Writing tests

Mirror the package under tests/ (for example, dascore/core/patch.py maps to tests/test_core/test_patch.py). Group related tests in classes and place fixtures as close as possible to their users: class, module, then conftest.py. Test observable boundaries and ensure a new regression test fails without its fix.