PYTHON-COVERAGE(1)

πŸ“¦ version 7.8.2, in debian trixie, ubuntu questing

πŸ’– 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 file RCFILE. 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 these PATTERNs. 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 these PATTERNs. 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 to DIR.
  • -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 to DIR.
  • --title TITLE β€” Use the text string TITLE as the title on the HTML.
  • --fail-under MIN β€” Exit with a status of 2 if the total coverage is less than MIN.
  • -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 of 2 if 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 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 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 .coverage data 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 of 2 if 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 to coverage.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: .coverage in the current working directory.
  • COVERAGE_OPTIONS β€” Space-separated series of command-line options to python-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 Β© 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