Skip to content

Enable per-test coverage contexts#160

Merged
IrishPrime merged 1 commit into
mainfrom
143/per-test-coverage-contexts
May 9, 2026
Merged

Enable per-test coverage contexts#160
IrishPrime merged 1 commit into
mainfrom
143/per-test-coverage-contexts

Conversation

@IrishPrime

Copy link
Copy Markdown
Owner

Set dynamic_context = "test_function" so coverage records which test exercised each covered line, and show_contexts = true under [tool.coverage.html] so the recorded contexts are actually surfaced in the HTML report. Without the HTML setting the contexts are captured but invisible.

After running pytest, each covered line in htmlcov/ exposes the list of originating tests, making "why is this branch covered?" and "which tests pull in this expensive import?" questions answerable from the report.

Resolve #143.

Set `dynamic_context = "test_function"` so `coverage` records which test
exercised each covered line, and `show_contexts = true` under
`[tool.coverage.html]` so the recorded contexts are actually surfaced in
the HTML report. Without the HTML setting the contexts are captured but
invisible.

After running `pytest`, each covered line in `htmlcov/` exposes the list
of originating tests, making "why is this branch covered?" and "which
tests pull in this expensive import?" questions answerable from the
report.

Resolve #143.
@IrishPrime IrishPrime self-assigned this May 9, 2026
@IrishPrime IrishPrime merged commit d1d2e2e into main May 9, 2026
3 checks passed
@IrishPrime IrishPrime deleted the 143/per-test-coverage-contexts branch May 9, 2026 01:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Enable per-test coverage contexts (dynamic_context = "test_function")

1 participant