pytest-cov
Pytest plugin for measuring coverage. Current version: 7.1.0. Released on March 2, 2026. Maintained with regular updates.
Warnings
- breaking Support for Python 3.8 has been dropped in pytest-cov 7.0.0.
- deprecated The '--cov-context' option may be removed in future versions.
Install
-
pip install pytest-cov
Quickstart
import os import pytest # Set the environment variable for the project directory os.environ['PROJECT_DIR'] = '/path/to/your/project' # Run pytest with coverage measurement pytest.main(['--cov', os.environ['PROJECT_DIR'], 'tests/'])