A simple experiment to trace coverage at a granularity finer than lines, using Python 3.11’s new debug ranges information (PEP 657).
After installation, use fine-coverage
or python -m fine_coverage
. It accepts the --cov
CLI option telling it what Python module to track coverage for, as well as a module name to run and its options:
fine-coverage --cov=mypackage pytest -v
In the above example, it will report which code in mypackage got executed while running the equivalent of python -m pytest -v.
Below you see an excerpt from the output when run on its own code. So far only tracks and, or, and if else expressions.
rm -rf dist
python -m build
pip install dist/*.whl
fine-coverage
is distributed under the terms of the GPL license.