PYTHON-COVERAGE(1)
π PYTHON-COVERAGE π
okay bestie, so python-coverage is a thing that exists in the Coverage corner of your man pages, and it's literally the manual for the python-coverage command. she's here to tell you which lines of your Python code actually ran and which ones were just standing there doing nothing. it's giving β¨accountabilityβ¨. let's go π«Ά
β¨ NAME β¨
python-coverage β measure code coverage of Python program execution π
πΈ SYNOPSIS πΈ
python-coverage command [ option ... ]
python-coverage help [ command ]
that's it, that's the shape of it. a command, some options if you're feeling fancy, and off you go. π
π¦ DESCRIPTION π¦
python-coverage runs a Python program, measures which of its statements get executed and which ones don't, and then reports those coverage measurements back to you. it's the friend who actually checks whether you did the thing. no cap, that's the whole deal. β¨
π COMMAND OVERVIEW π
here's the roster, the main characters, the whole cast:
python-coverage annotateβ Annotate source files with execution information.python-coverage combineβ Combine a number of data files.python-coverage debugβ Display diagnostic information about the internals of this program.python-coverage eraseβ Erase previously collected coverage data.python-coverage helpβ Get help on using coverage.py.python-coverage htmlβ Create an HTML report.python-coverage reportβ Report coverage stats on modules.python-coverage runβ Run a Python program and measure code execution.python-coverage xmlβ Create an XML report of coverage results.
pick your fighter, bestie π
π GLOBAL OPTIONS π
these ones apply up top, before you even get to the command-specific stuff:
--help,-hβ Describe how to use Coverage, in general or a command. the classic cry-for-help button, and she delivers π--rcfile RCFILEβ Specify configuration fileRCFILE. Defaults to.coveragerc. so if you don't say anything, she's reading.coveragerc, periodt.--omit PATTERN ...β Omit files when their filename matches one of thesePATTERNs. Usually needs quoting on the command line. β οΈ yes, the quoting thing is real, the shell is not playing.--include PATTERN ...β Include files only when their filename path matches one of thesePATTERNs. Usually needs quoting on the command line. same energy, opposite vibe π
π₯ COMMAND REFERENCE π₯
the deep dive. strap in. π§
π annotate
Annotate source files with execution information.
Options:
-d DIR,--directory DIRβ Write the output files toDIR.-i,--ignore-errorsβ Ignore errors while reading source files. (she's choosing peace, honestly π)
π combine PATH PATH [ ... ]
Combine data from multiple coverage files PATH, collected with run -p. The combined results are written to a single file representing the union of the data.
note the run -p bit β that's the parallel-mode run that makes all these separate files in the first place. iykyk π
π debug topic
Display information on the internals of coverage.py, for diagnosing problems.
Topics are:
data, to show a summary of the collected data.sys, to show installation information.
π erase
Erase previously collected coverage data.
π help [ command ]
Describe how to use Coverage.
π html [ option ... ] [ MODULE ... ]
Create an HTML report of the coverage of each MODULE file. Each file gets its own page, with the source decorated to show executed, excluded, and missed lines. it's giving glow-up for your source code β¨
Options:
-d DIR,--directory DIRβ Write the output files toDIR.--title TITLEβ Use the text stringTITLEas the title on the HTML.--fail-under MINβ Exit with a status of2if the total coverage is less thanMIN.-i,--ignore-errorsβ Ignore errors while reading source files.
π report [ option ... ] [ MODULE ... ]
Report coverage statistics on each MODULE.
Options:
--fail-under MINβ Exit with a status of2if the total coverage is less thanMIN.-i,--ignore-errorsβ Ignore errors while reading source files.-m,--show-missingβ Show line numbers of statements in each module that weren't executed. the receipts π
π run [ options ... ] PROGRAMFILE [ program_options ]
Run a Python program PROGRAMFILE, measuring code execution.
Options:
-a,--appendβ Append coverage data to.coverage, otherwise it is started clean with each run.--branchβ Measure branch coverage in addition to statement coverage. not just "did this line run" but "did this path get taken" π she's thorough.--debug DEBUGOPT,...β Debug optionsDEBUGOPT, separated by commas-L,--pylibβ Measure coverage even inside the Python installed library, which isn't done by default.-p,--parallel-modeβ Append the machine name, process id and random number to the.coveragedata file name to simplify collecting data from many processes. (yes, machine name + process id + random number. all three. iconic π₯)--timidβ Use a simpler but slower trace method. Try this if you get seemingly impossible results! π--source SOURCE ...β A list of packages or directories of code to be measured.
π xml [ options ... ] [ MODULES ... ]
Generate an XML report of coverage results on each MODULE.
Options:
--fail-under MINβ Exit with a status of2if the total coverage is less thanMIN.-i,--ignore-errorsβ Ignore errors while reading source files.-o OUTFILEβ Write the XML report toOUTFILE. Defaults tocoverage.xml.
π ENVIRONMENT VARIABLES π
the invisible settings, the ones living in your shell rent-free:
COVERAGE_FILEβ Path to the file where coverage measurements are collected to and reported from. Default:.coveragein the current working directory.COVERAGE_OPTIONSβ Space-separated series of command-line options topython-coverage. Default: empty.
π HISTORY π
The python-coverage command is a Python program which calls the coverage Python library to do all the work. (she's the face, the library is the brains π§ β¨)
The library was originally developed by Gareth Rees, and is now developed by Ned Batchelder. shoutout to both of them, legends only π
This manual page was written to document the python-coverage command for Debian. This is free software: you may copy, modify and/or distribute this work under the terms of the GNU General Public License, version 3 or later <http://www.gnu.org/licenses/> as published by the Free Software Foundation, version 3 or later. No warranty expressed or implied. (so like, free to use, free to share, but don't come for them if it breaks π«Ά)
On Debian systems, the complete text of the GNU General Public License version 3 can be found in the file /usr/share/common-licenses/GPL-3.
π AUTHOR π
Ben Finney <ben+python@benfinney.id.au>
π COPYRIGHT π
Copyright Β© 2010β2017 Ben Finney <bignose@debian.org>
and that's the whole page bestie!! πΈ this one's the Coverage manual, dated 2020-09-06 β she's a lil vintage but she ate and left no crumbs. go forth and get that coverage up, you've got this πβ¨π¦
π¦ where this page comes from
- debian trixie: python3-coverage 7.6.0+dfsg1-2+b2 Β· Apache-2
- ubuntu questing: python3-coverage 7.8.2+dfsg1-1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms