Coverage.py is a tool that measures how much of your Python code actually gets executed when you run your tests. Think of it as a way to find dead code, sections of your program that never run, either because they're unreachable or because your tests don't exercise them. This matters because untested code is more likely to have bugs hiding in it. Here's how it works in practice: you run your test suite through Coverage.py instead of running it directly, and it tracks which lines of code were executed and which were skipped. Afterward, it generates a report showing what percentage of your codebase was "covered" by tests, down to individual lines if you want that level of detail. For example, if you have an error-handling block that only triggers in rare conditions, Coverage.py will flag it as uncovered so you can decide whether to write a test for it or remove it. The tool integrates smoothly into existing Python workflows. You can use it with any Python test framework, and it works with Python 3.9 through 3.14, including some special variants like PyPy. Coverage.py can be configured with settings files to exclude certain lines you don't want to measure (like debug code or platform-specific sections), and it supports various reporting formats so you can see results however you prefer, as a percentage, as an HTML report, or in your CI/CD pipeline. Teams use this to enforce quality standards, many projects set a rule that new code must meet a certain coverage threshold, say 80%, before it can be merged. It's equally useful for developers just curious about whether their testing strategy is actually hitting the code paths they think it is. The tool has been around for years and is maintained actively, making it the standard choice in the Python ecosystem for coverage measurement.
← colesbury on gitmyhub — every repo by this author, as a profile.
Verify against the repo before relying on details.