🌐
PyPI
pypi.org › project › pytest-cov
pytest-cov · PyPI
Support for detailed coverage contexts (add --cov-context=test to have the full test name including parametrization as the context). Xdist support: you can use all of pytest-xdist’s features including remote interpreters and still get coverage.
      » pip install pytest-cov
    
Published   Mar 21, 2026
Version   7.1.0
🌐
GitHub
github.com › pytest-dev › pytest-cov
GitHub - pytest-dev/pytest-cov: Coverage plugin for pytest. · GitHub
Coverage plugin for pytest. Contribute to pytest-dev/pytest-cov development by creating an account on GitHub.
Starred by 2K users
Forked by 232 users
Languages   Python
Discussions

Set default --coverage-report in configuration file
Summary When computing coverage, I almost always want to use --coverage-report=term-missing. Instead of typing this on the command line every time, I would like to store this default in pyproject.t... More on github.com
🌐 github.com
18
August 28, 2024
python - How to get coverage reporting when testing a pytest plugin? - Stack Overflow
Context I am updating an inherited repository which has poor test coverage. The repo itself is a pytest plugin. I've changed the repo to use tox along with pytest-cov, and converted the "raw&q... More on stackoverflow.com
🌐 stackoverflow.com
How to run coverage for specific file
I’m in my project directory trying to test the coverage of my tests for utils.py using this command: coverage run --source=app/utils.py -m pytest test_app/test_utils.py I’m getting CoverageWarning messages saying utils was never imported and no data was collected. More on discuss.python.org
🌐 discuss.python.org
6
0
February 15, 2024
Which tool to use for pytest coverage reports: pytest-cov or coverage.py ?
pytest-cov is a tiny wrapper around coverage.py. There's really no reason to use coverage.py directly. More on reddit.com
🌐 r/learnpython
2
1
April 6, 2021
🌐
Readthedocs
pytest-cov.readthedocs.io
pytest-cov 7.1.0 documentation
pytest-cov 7.1.0 documentation · Overview · Configuration · Reporting · Debuggers and PyCharm · Distributed testing (xdist) Subprocess support · Contexts · Tox · Plugin coverage · Markers and fixtures · Changelog · Authors · Releasing · Contributing ·
🌐
Readthedocs
coverage.readthedocs.io › en › latest › source.html
Specifying source files — Coverage.py 7.13.5 documentation
You can further fine-tune coverage.py’s attention with the --include and --omit switches (or [run] include and [run] omit configuration values). --include is a list of file name patterns. If specified, only files matching those patterns will be measured. --omit is also a list of file name patterns, specifying files not to measure.
🌐
SourceForge
sourceforge.net › home › compare business software › application development › code coverage tools › pytest
Best Code Coverage Tools for pytest
Code coverage tools are software utilities designed to analyze the source code of an application and report on the level of code that is tested by automated tests. They usually measure the percentage of lines, blocks, or branches of code that have been executed in a test suite.
🌐
Slashdot
slashdot.org › software › application development › code coverage tools › pytest
Top Code Coverage Tools for pytest in 2026
The platform features automatic merging of reports across all CI systems and languages into a unified document. Users can receive tailored status updates on various coverage metrics and review reports organized by project, folder, and test type, such as unit or integration tests.
🌐
OneUptime
oneuptime.com › home › blog › how to configure pytest with coverage reporting on rhel
How to Configure pytest with Coverage Reporting on RHEL
March 4, 2026 - pytest with coverage reporting on RHEL gives you visibility into which parts of your Python codebase are tested and which are not. By configuring branch coverage, setting minimum thresholds, and integrating with CI/CD, you build a safety net ...
Find elsewhere
🌐
Stackademic
blog.stackademic.com › code-coverage-with-pytest-ensuring-quality-testing-in-your-python-projects-46d436941396
Code Coverage with Pytest: Ensuring Quality Testing in Your Python Projects | by Tomas Svojanovsky | Stackademic
April 25, 2024 - Code Coverage with Pytest: Ensuring Quality Testing in Your Python Projects Code coverage is useful because it tells us if we test enough. In big projects, we can easily find out if we forget to test …
🌐
GitHub
github.com › pytest-dev › pytest-cov › issues › 652
Set default --coverage-report in configuration file · Issue #652 · pytest-dev/pytest-cov
August 28, 2024 - Summary When computing coverage, I almost always want to use --coverage-report=term-missing. Instead of typing this on the command line every time, I would like to store this default in pyproject.t...
Author   adamjstewart
🌐
Code with C
codewithc.com › code with c › python tutorials › pytest coverage – how to use code coverage in python with pytest
Pytest Coverage - How To Use Code Coverage In Python With PyTest - Code With C
September 8, 2022 - Pytest is a fantastic library for writing unit tests. Pytest comes with a built-in feature called code coverage which measures how much code in your project is being tested by your tests.
🌐
Python Basics
python-basics-tutorial.readthedocs.io › en › latest › test › pytest › coverage.html
Coverage - Python Basics
3 weeks ago - Coverage.py is the favourite Python tool that measures code coverage. And pytest-cov is a popular pytest plugin that is often used in conjunction with Coverage.py.
🌐
Python Developer's Guide
devguide.python.org › testing › coverage
Increase test coverage
In these instances the module will appear to not have any coverage of global statements but will have proper coverage of local statements (for example, function definitions will not be traced, but the function bodies will).
🌐
PyPI
pypi.org › project › pytest-coverage
pytest-coverage · PyPI
Released: Jun 5, 2015 · No project description provided
      » pip install pytest-coverage
    
Published   Jun 05, 2015
Version   0.0.1
🌐
pytest
docs.pytest.org
pytest documentation
The pytest framework makes it easy to write small, readable tests, and can scale to support complex functional testing for applications and libraries.
🌐
Readthedocs
pytest-cov.readthedocs.io › en › latest › config.html
Configuration - pytest-cov 7.1.0 documentation
In practical terms this means that if you have multiple configuration files around (tox.ini, pyproject.toml or setup.cfg) you might need to use --cov-config to make coverage use the correct configuration file. Also, if you change the working directory and also use subprocesses in a test you might also need to use --cov-config to make pytest-cov use the expected configuration file in the subprocess.
🌐
GitHub
github.com › zubairwazir › Code-Coverage-and-Test-Coverage-Using-Pytest
GitHub - zubairwazir/Code-Coverage-and-Test-Coverage-Using-Pytest · GitHub
pytest -> run all the tests pytest -v -> run all the tests with more details ****************code coverage************ pip install coverage coverage run app.py coverage report coverage report -m (implicit command for details) coverage report --show-missing (explicit command for details) to write coverage report to xml and html coverage xml coverage html ****************test coverage************ pip install pytest-cov pytest --cov=src pytest -v --cov=src pytest -v --cov=src --cov-report=html pytest -v --cov=src --cov-report=xml Test code and save reports to the selected directory pytest --cov=src --cov-report=html:coverage-reports/htmlcov --cov-report=xml:coverage-reports/coverage.xml ************* Tests Paths************** sys.path.append("../") -> go one step back *******
Author   zubairwazir
Top answer
1 of 3
99

Instead of using the pytest-cov plugin, use coverage to run pytest:

coverage run -m pytest ....

That way, coverage will be started before pytest.

2 of 3
54

You can achieve what you want without pytest-cov.


❯ coverage run --source=<package> --module pytest --verbose <test-files-dirs> && coverage report --show-missing
OR SHORTER
❯ coverage run --source=<package> -m pytest -v <test-files-dirs> && coverage report -m
Example: (for your directory structure)
❯ coverage run --source=plugin_module -m pytest -v tests && coverage report -m
======================= test session starts ========================
platform darwin -- Python 3.9.4, pytest-6.2.4, py-1.10.0, pluggy-0.13.1 -- /Users/johndoe/.local/share/virtualenvs/plugin_module--WYTJL20/bin/python
cachedir: .pytest_cache
rootdir: /Users/johndoe/projects/plugin_module, configfile: pytest.ini
collected 1 items

tests/test_my_plugin.py::test_my_plugin PASSED               [100%]

======================== 1 passed in 0.04s =========================
Name                            Stmts   Miss  Cover   Missing
-------------------------------------------------------------
plugin_module/supporting_module.py  4      0   100%
plugin_module/plugin.py             6      0   100%
-------------------------------------------------------------
TOTAL                              21      0   100%

For an even nicer output, you can use:

❯ coverage html && open htmlcov/index.html


Documentation

❯ coverage -h
❯ pytest -h

coverage

run -- Run a Python program and measure code execution.

-m, --module --- Show line numbers of statements in each module that weren't executed.

--source=SRC1,SRC2, --- A list of packages or directories of code to be measured.

report -- Report coverage stats on modules.

-m, --show-missing --- Show line numbers of statements in each module that weren't executed.

html -- Create an HTML report.

pytest

-v, --verbose -- increase verbosity.

🌐
BrowserStack
browserstack.com › home › guide › how to generate pytest code coverage report
How to Generate Pytest Code Coverage Report | BrowserStack
July 3, 2025 - It studies the percentage of code executed using Pytest. Code coverage describes the extent to which a test suite has tested a codebase.
🌐
Codecov
docs.codecov.com › docs › code-coverage-with-python
Code coverage with Python
In this tutorial, we’ll use pytest -cov to generate a code coverage report locally.