Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Record and show contexts when using coverage #11518

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

slafs
Copy link
Sponsor

@slafs slafs commented May 2, 2024

As documented in https://coverage.readthedocs.io/en/7.5.0/contexts.html#dynamic-contexts

While working on #11517 I wanted to see which test is best to modify for the fix.
One way to easily find this out is to see which line is covered by which test.

This PR adds a dynamic context setting
and makes them show on the HTML coverage report.
The contexts are test function names.

NOTE pytest-cov plugin has even better support
for pytest test names as coverage contexts,
but I think this PR is already an imporovement.

As documented in https://coverage.readthedocs.io/en/7.5.0/contexts.html#dynamic-contexts

While working on tiangolo#11517 I wanted to see which test
is best to modify for the fix.
One way to easily find this out is to see which line is covered
by which test.

This PR adds a dynamic context setting
and makes them show on the HTML coverage report.
The contexts are test function names.

NOTE pytest-cov plugin has even better support
for pytest test names as coverage contexts,
but I think this PR is already an imporovement.
@@ -206,7 +206,7 @@ source = [
"tests",
"fastapi"
]
context = '${CONTEXT}'
Copy link
Sponsor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, not sure what this piece was for TBH 😅. Decided to remove it though.

@tiangolo
Copy link
Owner

tiangolo commented May 2, 2024

📝 Docs preview for commit 84bc7c6 at: https://1ba1b8ae.fastapitiangolo.pages.dev

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.

None yet

2 participants