You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
FEAT: support running coverage measurements through coverage.py directly, instead of via pytest-cov #330
I discovered this while helping on #207, but the issue I want to report is actually quite orthogonal to that PR, so I'm opening this ticket separately.
In short, I would like to make pytest-cov a choice rather than a hard requirement for coverage reporting; this plugin is merely more than a middle man and provides no actual functionality on its own, so I would like to eliminate it from dependency graphs to reduce the "attack surface" (not exclusively, but also in the security sense) for dependees.
Running coverage directly isn't really challenging in itself, it should be as simple as the following substitution:
pytest ... --cov --cov-report=xml
coverage run --parallel-mode -m pytest
coverage combine
coverage xml
Note that, by virtue of coverage being a hard dependency to pytest-cov, it would be perfectly backwards compatible to use it directly.
The difficulty lies in how to approach this; here's a summary of the design constraints we're facing.
tox.yml (via tox itself) can only append arguments to a command via matrix.pytest_flag, which tox redirects as posargs
in order to automatically form a coverage command dynamically, I need to be able to prependcoverage run -m before the pytest invoke
I would also need to somehow be able to add dynamically generated commands to invoke coverage combine or coverage xml ...
This just seems impossible to do in the most general case. My preferred solution would be to renounce doing this stuff dynamically and let users define their own commands (using pytest-cov or coverage directly, at their discretion); but of course that'd be a breaking change. I will try to come up with a backward compatible transition plan.
Activity
AryaBhatt45 commentedon Nov 20, 2025
neutrinoceros commentedon Nov 20, 2025
AryaBhatt45 commentedon Nov 21, 2025
neutrinoceros commentedon Nov 21, 2025
AryaBhatt45 commentedon Nov 22, 2025
neutrinoceros commentedon Nov 22, 2025
Flamki commentedon Feb 18, 2026
saksham242007 commentedon Feb 24, 2026
Cadair commentedon Mar 24, 2026
The backwards compatible-ness of this related to #383.
Although, I'm in the camp of it's not worth making things more complex for the sake of removing pytest-cov.