---
source: https://iinventedlight.com/library/notes/coverage-py-run.md
title: "coverage run measures a program, and --source or --omit decide which files are included"
license: CC-BY-4.0
license_url: https://creativecommons.org/licenses/by/4.0/
source_license: "Apache-2.0 (coverage.py docs); prose restates cited source lines in own words"
license_family: mixed-green
attribution: "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)."
author: "iinventedlight (synthesis of cited sources); text drafted with AI assistance"
date: 2026-11-18
status: published
approved_by: "Cole Withington, 2026-11-20 13:14 PT: \"Publish the full batch and rewrite the 6 live notes\""
checked_on: 2026-11-18
as_of: 2026-11-18
confidence: medium
untested: "Not reproduced (2026-11-18). Official docs and source files were read; no test suite, server, or API call was run for this note."
category: coding-references
topic_area: "code-python: coverage.py run"
tags: [coverage, pytest, testing, coverage-py]
client: Librarian
sources:
  - id: S1
    title: "coverage run command"
    publisher: nedbat/coveragepy (GitHub)
    url: https://github.com/nedbat/coveragepy/blob/main/doc/commands/cmd_run.rst
    accessed: 2026-11-18
    license: "Apache-2.0"
  - id: S2
    title: "coverage command line (website)"
    publisher: coverage.py (Read the Docs)
    url: https://coverage.readthedocs.io/en/7.6.1/cmd.html
    accessed: 2026-11-18
    license: "Apache-2.0"
---
# 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

- id: C1
  claim: --source limits measurement to listed directories or packages.
  source: S1
  evidence: "coverage run --source=dir1,dir2 my_program.py arg1 arg2"

- id: C2
  claim: --omit skips files whose paths match the given patterns.
  source: S1
  evidence: "Omit files whose paths match one of these patterns"

- id: C3
  claim: The documented usage form is coverage run with options and a program.
  source: S2
  evidence: "Usage: coverage run [options] <pyfile> [program options]"

- id: C4
  claim: coverage report prints a report after a run.
  source: S2
  evidence: "Usage: coverage report [options] [modules]"

## Sources

- [S1] coverage run command. nedbat/coveragepy (GitHub). https://github.com/nedbat/coveragepy/blob/main/doc/commands/cmd_run.rst . License: Apache-2.0. Accessed 2026-11-18.

- [S2] coverage command line (website). coverage.py (Read the Docs). https://coverage.readthedocs.io/en/7.6.1/cmd.html . License: Apache-2.0. Accessed 2026-11-18.

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.

---

Agents: [/agents.md](/agents.md) | [/.well-known/agent-library.json](/.well-known/agent-library.json).
