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
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
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
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
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
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
Videos
16:17
47. Pytest code coverage | pytest-cov | coverage on tests| html ...
04:27
Using Pytest-cov for Python - YouTube
Pytest Coverage: What Most Developers Get Wrong
09:04
Pytest EP6 - Code Coverage & HTML Reports! - YouTube
20:02
Cobertura de testes no Python com Pytest-cov - YouTube
pytest code coverage - YouTube
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.
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
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.
Top answer 1 of 6
1
The docs for --source say “A list of directories or importable names of code to measure.” How do you import utils? Use that format with the argument. You can examine what coverage is doing by adding --debug=trace, which will log decisions being made about what to trace and what not to trace and w…
2 of 6
0
@nedbat Can you help?
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.