Skip to content

Add test coverage #7414

Open
Open
@chrahunt

Description

@chrahunt

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:

  1. Not possible to quickly identify gaps in test coverage
  2. Can't use test techniques like mutation testing, which depend on coverage data
  3. 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:

  1. record coverage details for the pip package and sub-packages/modules, as invoked by:
    1. unit tests directly
    2. tests using the script/virtualenv pytest fixture (see tests/conftest.py -> virtualenv_template)
    3. pip itself, as part of build_env.BuildEnvironment.install_requirements
  2. exclude vendored libraries
  3. exclude type-only code (guarded with if MYPY_CHECK_RUNNING)
  4. exclude Python 2 on Python 3 and vice-versa
  5. combine the coverage results for all pips, which may have different paths
  6. 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

  1. Do nothing, which comes at the cost of not having the initially mentioned capabilities

Additional context

Metadata

Metadata

Assignees

No one assigned

    Labels

    C: testsTesting and related thingstype: maintenanceRelated to Development and Maintenance Processes

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions