What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Install pytest-cov, then run pytest --cov=YOUR_PACKAGE tests/. Replace YOUR_PACKAGE with the importable package or source path you want to measure, and tests/ with your test directory. This produces a coverage summary in the terminal. To see unexecuted line numbers and create a browsable HTML report, run:
python -m pip install pytest-cov
pytest --cov=YOUR_PACKAGE --cov-report=term-missing --cov-report=html tests/
The HTML report is written to htmlcov/ by default; open htmlcov/index.html in a browser. The instructions below cover report formats, source selection, repeatable configuration, and common problems. The current stable pytest-cov documentation is for version 7.1.0, updated March 21, 2026.
Install pytest-cov and run a first report
-
Install the plugin into the same Python environment used to run your tests:
python -m pip install pytest-cov -
From the project root, run pytest with the package or path to measure:
Recommended: Fix Windows Errors and Clear Junk Files in Minutes - Free Scan →Recommended: Update Every Outdated Driver on Your PC in One Scan - Free →Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.#1 Best Overall
pytest --cov=YOUR_PACKAGE tests/ -
Read the terminal summary. The default output reports statements, missed statements, and a coverage percentage. It is a line-coverage measure; it does not by itself show which uncovered line numbers need attention.
pytest-cov is the pytest plugin that collects coverage while the test suite runs. The project README provides the installation and basic invocation pattern: pytest-cov on GitHub.
Show missing lines and create an HTML report
For a more useful local report, request both terminal detail and HTML output in the same test run:
pytest --cov=YOUR_PACKAGE
--cov-report=term-missing
--cov-report=html
tests/
term-missing adds uncovered line numbers to the terminal summary. The HTML report is created in htmlcov/ unless you specify another destination. Open htmlcov/index.html to navigate the files and inspect coverage by line.
Do these 3 things before closing this tab:
1Fix the driver behind crashes, sound loss and screen glitches2Repair Windows errors before they cause bigger problems3Scan for outdated or missing drivers - takes under a minutepytest-cov supports several report types and destinations; see its reporting documentation for current syntax and options.
Rank #2
Choose a report format and destination
| Format | Command option | Typical use |
|---|---|---|
| Terminal summary | --cov-report=term |
Quick result in a local shell or CI log. |
| Terminal with missing lines | --cov-report=term-missing |
See which line numbers were not executed. Add :skip-covered to omit files with full coverage. |
| HTML | --cov-report=html or --cov-report=html:coverage-html |
Browse annotated results locally. The destination is a directory. |
| XML | --cov-report=xml or --cov-report=xml:coverage.xml |
Provide a file for a downstream tool expecting XML. |
| JSON | --cov-report=json or --cov-report=json:coverage.json |
Feed structured coverage data to another process. |
| Markdown | --cov-report=markdown:coverage.md |
Write a Markdown report; append mode is also supported. |
| LCOV | --cov-report=lcov:coverage.info |
Provide an LCOV file for a compatible consumer. |
| Annotated source | --cov-report=annotate:coverage-annotated |
Create annotated source output in a directory. |
Once you specify any --cov-report option, pytest-cov does not add its default terminal report automatically. Include --cov-report=term or --cov-report=term-missing when you also want terminal output. To collect coverage data without producing a report during that run, use the empty option --cov-report=.
Example: terminal details, HTML, and XML together
pytest --cov=YOUR_PACKAGE
--cov-report=term-missing
--cov-report=html:coverage-html
--cov-report=xml:coverage.xml
tests/
This writes the HTML report to the coverage-html/ directory and XML to coverage.xml, while printing missing-line details. Other report destinations work the same way: TYPE:DEST. HTML and annotate destinations are directories; XML, JSON, Markdown, and LCOV destinations are files.
Choose the code to measure
Use --cov=YOUR_PACKAGE to select the package or path whose execution should count. Replace the example name with your actual importable package or source location; do not leave the placeholder in the command. You can pass multiple --cov values when you intentionally want to measure more than one target.
Recommended Free Tools
If your coverage configuration already defines source, a valued --cov=... option overrides that setting. In that case, use bare --cov to let the configured source selection apply rather than duplicating it on the command line. See pytest-cov’s configuration documentation for the interaction between pytest-cov and coverage configuration.
Make coverage run on every pytest invocation
To avoid retyping the options, add them to pytest’s configuration. For example, in pyproject.toml:
[tool.pytest.ini_options]
addopts = "--cov=YOUR_PACKAGE --cov-report=term-missing"
Replace YOUR_PACKAGE with your project’s target. Because --cov takes an optional value, do not leave it as the last token in addopts if it could consume the next command-line argument. If you deliberately need an empty value, write --cov=.
Projects may have multiple configuration files, such as tox.ini, pyproject.toml, and setup.cfg. If the wrong coverage settings appear to be active, specify the intended file with --cov-config=PATH. The special default name .coveragerc can also lead coverage.py to check other supported configuration files. Subprocesses or tests that change working directory may need an explicit configuration path as well.
The Tool Desk
Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →Measure branches, enforce a minimum, or combine runs
Branch coverage
Line coverage records whether executable lines ran. Branch coverage also measures alternate control-flow paths. Enable it for a run with:
pytest --cov=YOUR_PACKAGE --cov-branch tests/
It can also be enabled in coverage configuration under [run] with the branch setting. Branch coverage answers a different question from line coverage, so use it when exercising alternatives in conditions and control flow matters to your team.
Fail below a coverage threshold
Use --cov-fail-under=MIN to make pytest-cov fail when the total percentage is below your chosen minimum. For example, a project choosing a 90 percent gate could run:
pytest --cov=YOUR_PACKAGE --cov-fail-under=90 tests/
The threshold is a project policy, not a recommended universal target. coverage.py documents a status code of 2 when its reporting --fail-under threshold is missed; pytest-cov also documents its corresponding threshold option. Check the coverage.py reporting reference when integrating reporting behavior into CI.
Append data from separate runs
pytest-cov normally starts with clean coverage data for a run. Add --cov-append only when you intentionally want to accumulate results from multiple runs. The resulting data file can then be inspected with normal coverage tools.
Keep context about which test ran
For test-level context in coverage data, use --cov-context=test. pytest-cov documents dynamic contexts that include test names and parametrization, which can help investigate which tests exercised a line.
Troubleshoot missing or unexpected output
-
The report covers the wrong files or includes tests. Set
--cov=YOUR_PACKAGEto the application package or source path. If the source is defined in coverage configuration, use bare--covinstead; a valued option overrides configuredsource. -
No terminal table appears. If you specified any report options, add
--cov-report=termor--cov-report=term-missingexplicitly. A saved HTML or XML report does not imply terminal output.Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy. -
A report is missing or in an unexpected location. Give an explicit destination, such as
--cov-report=html:coverage-htmlor--cov-report=xml:coverage.xml. Confirm whether the selected report writes to a directory or file. -
Coverage configuration seems ignored. Look for competing
tox.ini,pyproject.toml, andsetup.cfgsettings, then select the intended file with--cov-config=PATH. Account for subprocesses and working-directory changes if applicable. -
Tests fail and you still need coverage output. By default, pytest-cov reports coverage even when tests fail. The
--no-cov-on-failoption changes that behavior; its default is false.
Or skip the browser setup:
If you also need website screenshots for test documentation or another developer workflow, ScreenshotNeo provides a screenshot API and MCP server. One GET request returns an image or PDF; for example:
Quick wins for a faster PC:
Repair Windows errors before they cause bigger problemsFix Now →Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →Clear out junk files and repair common Windows errorsFree Scan →curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
See the ScreenshotNeo API documentation for parameters. It removes cookie banners, newsletter popups, and chat widgets before capture; bot checks, blank pages, and failed loads are not billed. Its MCP server lets AI agents take screenshots. The free plan includes 1,000 screenshots a month with no card, and paid plans start at $5 for 3,000. Learn more at ScreenshotNeo, or sign up free for 1,000 screenshots a month with no card.
Frequently Asked Questions
Does pytest-cov measure branch coverage by default?
No. Enable it explicitly with --cov-branch or the branch setting in coverage configuration.
Can pytest-cov create more than one report in a run?
Yes. Repeat --cov-report with the formats and destinations you need; include a terminal report option if you also want terminal output.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




