-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
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 test coverage contexts (what test covers which line) #11518
⚙️ Record and show test coverage contexts (what test covers which line) #11518
Conversation
As documented in https://coverage.readthedocs.io/en/7.5.0/contexts.html#dynamic-contexts While working on fastapi#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}' |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This env var is used by/with GitHub Actions so that coverage can know where to store the coverage files, that way they can be combined later. So I think doing this trick wouldn't work. 🤔
📝 Docs preview for commit 84bc7c6 at: https://1ba1b8ae.fastapitiangolo.pages.dev |
📝 Docs preview for commit 4d91bb0 at: https://7c1f359a.fastapitiangolo.pages.dev |
I was checking the docs, and it seems both contexts can be combined, so we can know which Python version and which tests ran each function. 🎉 🚀 https://coverage.readthedocs.io/en/7.6.1/contexts.html#dynamic-contexts I updated that bit to get that. 🤓 Thank you for your contribution! 🍰 |
…e) (fastapi#11518) Co-authored-by: Sebastián Ramírez <[email protected]>
…e) (fastapi#11518) Co-authored-by: Sebastián Ramírez <[email protected]>
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.