pytest-subtests icon indicating copy to clipboard operation
pytest-subtests copied to clipboard

Support coverage.py dynamic contexts when coverage is being collected

Open Julian opened this issue 2 years ago • 0 comments

coverage.py supports a notion of "dynamic contexts".

The most common reason for these is answering "what tests cover a particular line" in the coverage output -- but right now that information doesn't descend into subtests, so you just see one single context reported when looking at output.

E.g. here's a screenshot from a project where I'm running like 200 subtests within a single test (called test_referencing_suite), only a few of which are going to really cover this line, even though it gets reported as "1 ctx":

Screenshot 2023-05-24 at 14 17 44

I think the way to do this is by including a coverage plugin which is aware of when/how subtests are entered (and to conditionally call into it if coverage is being collected) though I haven't looked closely to be honest, figured I'd file this and see if there's any appetite first for even including this here.

Julian avatar May 24 '23 18:05 Julian