tiangolo / fastapi

FastAPI framework, high performance, easy to learn, fast to code, ready for production
https://fastapi.tiangolo.com/
MIT License
73.34k stars 6.18k forks source link

Record and show contexts when using coverage #11518

Open slafs opened 2 months ago

slafs commented 2 months ago

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.

tiangolo commented 2 months ago

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