python-coverage(1)
π python-coverage β the manual page, but make it cute
okay bestie, grab a boba, because we're about to learn python-coverage, which lives in the Coverage section of your manual (that's the manual name, and you're gonna see it everywhere, iykyk π).
β¨ SYNOPSIS β¨
python-coverage command [ option ... ]
python-coverage help [ command ]
πΈ DESCRIPTION πΈ
So basically python-coverage runs your Python program, watches very closely which lines actually get executed and which ones just sit there like wallflowers π, and then reports all those coverage measurements back to you. It's giving surveillance but make it helpful.
π COMMAND OVERVIEW π
Here's the whole roster, main character energy for days:
python-coverage annotateβ annotate your source files with execution info. Little notes everywhere, so cute.python-coverage combineβ combine a bunch of data files into one. Bestie behavior: uniting the squad π«Άpython-coverage debugβ show diagnostic info about the internals of this program. Peek behind the curtain πpython-coverage eraseβ erase previously collected coverage data. Not me hitting delete on the past.python-coverage helpβ get help on using coverage.py. We love a supportive icon.python-coverage htmlβ create an HTML report. Pretty pages, slay.python-coverage reportβ report coverage stats on modules. The receipts πpython-coverage runβ run a Python program and measure code execution. The whole point, honestly.python-coverage xmlβ create an XML report of coverage results. For the machine-girlies π€
β GLOBAL OPTIONS β
--help,-hβ describes how to use Coverage, either in general or for a specific command. Your SOS button π--rcfile RCFILEβ specify the configuration file RCFILE. The default is.coveragerc. Like a settings file but with a shadowy dot in front.--omit PATTERN ...β omit files when their filename matches one of these *PATTERN*s. Ngl, this usually needs quoting on the command line.--include PATTERN ...β include files only when their filename path matches one of these *PATTERN*s. Also usually needs quoting on the command line, fr fr.
π₯ COMMAND REFERENCE π₯
annotate π
Options:
-d DIR,--directory DIRβ write the output files to DIR.-i,--ignore-errorsβ ignore errors while reading source files. We're unbothered π
combine PATH PATH [ ... ] π¦
Combine data from multiple coverage files PATH, collected with run -p. The combined results get written to a single file that represents the union of the data. One file to rule them all β¨
debug topic π
Display information on the internals of coverage.py, for diagnosing problems. Love a deep dive.
Topics are:
data, to show a summary of the collected data.sys, to show installation information.
erase πͺοΈ
Erase previously collected coverage data. Gone. Poof. Periodt.
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 scrapbook.
Options:
-d DIR,--directory DIRβ write the output files to DIR.--title TITLEβ use the text string TITLE as the title on the HTML.--fail-under MINβ exit with a status of2if the total coverage is less than MIN. Failing with flair.-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 than MIN.-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 callout post, but constructive.
run [ options ... ] PROGRAMFILE [ program_options ] πββοΈπ¨
Run a Python program PROGRAMFILE, measuring code execution. The main event.
Options:
-a,--appendβ append coverage data to.coverage; otherwise it's started clean with each run. Fresh start vs. building the lore.--branchβ measure branch coverage in addition to statement coverage. Two types of coverage, double the power β¨--debug DEBUGOPT,...β debug options DEBUGOPT, 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. Chaos-coordinated π--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 than MIN.-i,--ignore-errorsβ ignore errors while reading source files.-o OUTFILEβ write the XML report to OUTFILE. Defaults tocoverage.xml.
π§ ENVIRONMENT VARIABLES π§
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. No cap, it's the library doing the heavy lifting.
The library was originally developed by Gareth Rees, and is now developed by Ned Batchelder. Shoutout to both π
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.
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 thing bestie, dated 2020-09-06, from the Coverage manual (that python-coverage(1) footer vibe). go measure some lines, you're gonna slay π«Άπβ¨
π¦ where this page comes from
- ubuntu stonking: python3-coverage 7.16.1+dfsg1-1 Β· Apache-2
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms