Skip to content
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

Document show_contexts #473

Merged
merged 1 commit into from
Jun 1, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion docs/contexts.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@
Contexts
========

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

.. _`different_contexts`: https://coverage.readthedocs.io/en/stable/contexts.html

The context name recorded in the coverage.py database is the pytest test id,
and the phase of execution, one of "setup", "run", or "teardown". These two
are separated with a pipe symbol. You might see contexts like::
Expand All @@ -16,3 +18,12 @@ are separated with a pipe symbol. You might see contexts like::

Note that parameterized tests include the values of the parameters in the test
id, and each set of parameter values is recorded as a separate test.

To view contexts when using ``--cov-report=html``, add this to your ``.coveragerc``::

[html]
show_contexts = True
The HTML report will include an annotation on each covered line, indicating the
number of contexts that executed the line. Clicking the annotation displays a
list of the contexts.