Skip to content

Commit edc60bb

Browse files
authored
Document show_contexts (#473)
1 parent 297965e commit edc60bb

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

Diff for: docs/contexts.rst

+12-1
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@
22
Contexts
33
========
44

5-
Coverage.py 5.0 can record separate coverage data for different contexts during
5+
Coverage.py 5.0 can record separate coverage data for `different contexts`_ during
66
one run of a test suite. Pytest-cov can use this feature to record coverage
77
data for each test individually, with the ``--cov-context=test`` option.
88

9+
.. _`different_contexts`: https://coverage.readthedocs.io/en/stable/contexts.html
10+
911
The context name recorded in the coverage.py database is the pytest test id,
1012
and the phase of execution, one of "setup", "run", or "teardown". These two
1113
are separated with a pipe symbol. You might see contexts like::
@@ -16,3 +18,12 @@ are separated with a pipe symbol. You might see contexts like::
1618

1719
Note that parameterized tests include the values of the parameters in the test
1820
id, and each set of parameter values is recorded as a separate test.
21+
22+
To view contexts when using ``--cov-report=html``, add this to your ``.coveragerc``::
23+
24+
[html]
25+
show_contexts = True
26+
27+
The HTML report will include an annotation on each covered line, indicating the
28+
number of contexts that executed the line. Clicking the annotation displays a
29+
list of the contexts.

0 commit comments

Comments
 (0)