← All notes

coverage run measures a program, and --source or --omit decide which files are included

Answer: coverage run starts a Python program and records which lines ran. Pass the program and its arguments after the options: coverage run --source=dir1,dir2 my_program.py arg1 arg2. --source, --include, and --omit choose the files to measure.

Selecting code

--source names packages or directories to measure. --omit takes patterns for files to skip. You can also use -m to run a module the way python -m would.

Reporting

The command reference also documents coverage report.

Claims

Sources

License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: nedbat/coveragepy (GitHub), coverage run command, Apache-2.0 (https://raw.githubusercontent.com/nedbat/coveragepy/main/LICENSE.txt); coverage.py (Read the Docs), coverage command line (website), Apache-2.0 (https://raw.githubusercontent.com/nedbat/coveragepy/main/LICENSE.txt). Text was condensed and changed from the originals.

License: CC-BY-4.0 · Summary by iinventedlight (AI-assisted). Sources: nedbat/coveragepy (GitHub), coverage run command, Apache-2.0 (https://raw.githubusercontent.com/nedbat/coveragepy/main/LICENSE.txt); coverage.py (Read the Docs), coverage command line (website), Apache-2.0 (https://raw.githubusercontent.com/nedbat/coveragepy/main/LICENSE.txt).

Cite this

Permanent ID: iil:note:qef6x3r2

iinventedlight. 2026. "coverage run measures a program, and --source or --omit decide which files are included." iinventedlight Library, iil:note:qef6x3r2, version of 2026-11-18. https://iinventedlight.com/library/notes/coverage-py-run/. License: CC-BY-4.0.

@misc{iil_note_qef6x3r2,
  author = {{iinventedlight}},
  title = {{coverage run measures a program, and --source or --omit decide which files are included}},
  howpublished = {iinventedlight Library},
  year = {2026},
  date = {2026-11-18},
  url = {https://iinventedlight.com/library/notes/coverage-py-run/},
  note = {Permanent ID iil:note:qef6x3r2. License: CC-BY-4.0.},
}

Markdown

Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com. Or Report a correction (no account needed).

For language models and agents: start at /llms.txt | /agents.md | /.well-known/agent-library.json. This page in Markdown: /library/notes/coverage-py-run.md.