Configuration

New in version 0.3.0.

When using Coverage.py’s reporting commands it may be desirable to generate a report for a different Python version / implementation / platform to the current one. For instance, you are generating a report from a .coverage file produced on PyPy 3.6 on Windows, but you are running CPython 3.8 on Linux.

coverage_pyver_pragma provides three environment variables which can be used to set the target version and platform.

COV_PYTHON_VERSION

Sets the Python version. Must be in the form <major>.<minor>.

Defaults to the output of '.'.join(platform.python_version_tuple()[:2]).

Example:

COV_PYTHON_VERSION=3.6 coverage report
COV_PLATFORM

Sets the Python platform. Must be a string which matches the output of platform.system() on the desired platform.

Defaults to the output of platform.system().

Example:

COV_PLATFORM=Windows coverage report
COV_PYTHON_IMPLEMENTATION

Sets the Python implementation. Must be a string which matches the output of platform.python_implementation() with the desired implementation.

Defaults to the output of platform.python_implementation().

Example:

COV_PYTHON_IMPLEMENTATION=PyPy coverage report

If you generate your coverage reports through tox you should configure passenv to ensure the environment variables are passed through:

[testenv]
passenv =
    COV_PYTHON_VERSION
    COV_PLATFORM
    COV_PYTHON_IMPLEMENTATION