Open
Description
What's the problem this feature will solve?
Currently, pip does not have any coverage tracking integrated into its test suite. This comes with a few downsides:
- Not possible to quickly identify gaps in test coverage
- Can't use test techniques like mutation testing, which depend on coverage data
- Can't use it as a factor for PR evaluation
The current tox environment configured with coverage-py3
is limited to unit tests only.
Describe the solution you'd like
In a separate tox target, configure pytest-cov
/coverage
to:
- record coverage details for the pip package and sub-packages/modules, as invoked by:
- unit tests directly
- tests using the
script
/virtualenv
pytest fixture (seetests/conftest.py -> virtualenv_template
) - pip itself, as part of
build_env.BuildEnvironment.install_requirements
- exclude vendored libraries
- exclude type-only code (guarded with
if MYPY_CHECK_RUNNING
) - exclude Python 2 on Python 3 and vice-versa
- combine the coverage results for all pips, which may have different paths
- support getting coverage while using local paralellization with xdist (i.e.
-n
option)
If it helps, this could be done in Python 3 only (at first).
I have a basic first implementation here, but when combining the coverage reports the records from the integration tests seemed to be dropped.
Alternative Solutions
- Do nothing, which comes at the cost of not having the initially mentioned capabilities
Additional context
- Add a coverage job for Python 3 #4862 - coverage targeting unit tests added