File tree 1 file changed +12
-1
lines changed
1 file changed +12
-1
lines changed Original file line number Diff line number Diff line change 2
2
Contexts
3
3
========
4
4
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
6
6
one run of a test suite. Pytest-cov can use this feature to record coverage
7
7
data for each test individually, with the ``--cov-context=test `` option.
8
8
9
+ .. _`different_contexts` : https://coverage.readthedocs.io/en/stable/contexts.html
10
+
9
11
The context name recorded in the coverage.py database is the pytest test id,
10
12
and the phase of execution, one of "setup", "run", or "teardown". These two
11
13
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::
16
18
17
19
Note that parameterized tests include the values of the parameters in the test
18
20
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.
You can’t perform that action at this time.
0 commit comments