Skip to content

Commit 73424e3

Browse files
committed
Cleanup the docs a bit.
1 parent 36f1cc2 commit 73424e3

File tree

2 files changed

+48
-44
lines changed

2 files changed

+48
-44
lines changed

README.rst

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ Overview
1313
- |github-actions|
1414
* - package
1515
- |version| |conda-forge| |wheel| |supported-versions| |supported-implementations| |commits-since|
16+
1617
.. |docs| image:: https://readthedocs.org/projects/pytest-cov/badge/?style=flat
1718
:target: https://readthedocs.org/projects/pytest-cov/
1819
:alt: Documentation Status
@@ -45,10 +46,11 @@ Overview
4546

4647
.. end-badges
4748
48-
This plugin produces coverage reports. Compared to just using ``coverage run`` this plugin does some extras:
49+
This plugin provides coverage functionality as a pytest plugin. Compared to just using ``coverage run`` this plugin does some extras:
4950

50-
* Subprocess support: you can fork or run stuff in a subprocess and will get covered without any fuss.
51-
* Xdist support: you can use all of pytest-xdist's features and still get coverage.
51+
* Automatic erasing and combination of .coverage files and default reporting.
52+
* Support for detailed coverage contexts (add ``--cov-context=test`` to have the full test name including parametrization as the context).
53+
* Xdist support: you can use all of pytest-xdist's features including remote interpreters and still get coverage.
5254
* Consistent pytest behavior. If you run ``coverage run -m pytest`` you will have slightly different ``sys.path`` (CWD will be
5355
in it, unlike when running ``pytest``).
5456

@@ -68,11 +70,10 @@ For distributed testing support install pytest-xdist::
6870

6971
pip install pytest-xdist
7072

71-
Upgrading from ancient pytest-cov
72-
---------------------------------
73+
Upgrading from pytest-cov 6.3
74+
-----------------------------
7375

74-
`pytest-cov 2.0` is using a new ``.pth`` file (``pytest-cov.pth``). You may want to manually remove the older
75-
``init_cov_core.pth`` from site-packages as it's not automatically removed.
76+
`pytest-cov 6.3` and older were using a ``.pth`` file to enable coverage measurements in subprocesses. This was removed in `pytest-cov 7` - use `coverage's patch options <https://coverage.readthedocs.io/en/latest/config.html#run-patch>`_ to enable subprocess measurements.
7677

7778
Uninstalling
7879
------------
@@ -111,10 +112,6 @@ Documentation
111112
https://pytest-cov.readthedocs.io/en/latest/
112113

113114

114-
115-
116-
117-
118115
Coverage Data File
119116
==================
120117

@@ -132,12 +129,6 @@ For distributed testing the workers must have the pytest-cov package installed.
132129
the plugin must be registered through setuptools for pytest to start the plugin on the
133130
worker.
134131

135-
For subprocess measurement environment variables must make it from the main process to the
136-
subprocess. The python used by the subprocess must have pytest-cov installed. The subprocess must
137-
do normal site initialisation so that the environment variables can be detected and coverage
138-
started. See the `subprocess support docs <https://pytest-cov.readthedocs.io/en/latest/subprocess-support.html>`_
139-
for more details of how this works.
140-
141132
Security
142133
========
143134

docs/reporting.rst

Lines changed: 40 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@ Reporting
33

44
It is possible to generate any combination of the reports for a single test run.
55

6-
The available reports are terminal (with or without missing line numbers shown), HTML, XML, JSON, Markdown (either in 'write' or 'append' mode to file), LCOV and
7-
annotated source code.
6+
The available reports are terminal (with or without missing line numbers shown), HTML, XML, JSON, Markdown (either in 'write' or 'append'
7+
mode to file), LCOV and annotated source code.
88

9-
The terminal report without line numbers (default)::
9+
The default is terminal report without line numbers::
1010

11-
pytest --cov-report term --cov=myproj tests/
11+
pytest --cov=myproj tests/
1212

1313
-------------------- coverage: platform linux2, python 2.6.4-final-0 ---------------------
1414
Name Stmts Miss Cover
@@ -22,7 +22,7 @@ The terminal report without line numbers (default)::
2222

2323
The terminal report with line numbers::
2424

25-
pytest --cov-report term-missing --cov=myproj tests/
25+
pytest --cov-report=term-missing --cov=myproj tests/
2626

2727
-------------------- coverage: platform linux2, python 2.6.4-final-0 ---------------------
2828
Name Stmts Miss Cover Missing
@@ -49,32 +49,45 @@ The terminal report with skip covered::
4949

5050
You can use ``skip-covered`` with ``term-missing`` as well. e.g. ``--cov-report term-missing:skip-covered``
5151

52-
The report options below output to files without showing anything on the terminal::
52+
If any reporting options are used then the default (``--cov-report=term`` is not added automatically). For example this would not show any
53+
terminal output:
54+
55+
.. code-block:: bash
5356
5457
pytest --cov-report html
55-
--cov-report xml
56-
--cov-report json
57-
--cov-report markdown
58-
--cov-report markdown-append:cov-append.md
59-
--cov-report lcov
60-
--cov-report annotate
61-
--cov=myproj tests/
62-
63-
The output location for each of these reports can be specified. The output location for the XML, JSON, Markdown and LCOV
64-
report is a file. markdown-append option is specially useful for appending the report to an existing file. Example for GitHub Actions:
65-
--cov-report=markdown-append:${GITHUB_STEP_SUMMARY}. Where as the output location for the HTML and annotated source code reports are
66-
directories::
58+
--cov-report xml
59+
--cov-report json
60+
--cov-report markdown
61+
--cov-report markdown-append:cov-append.md
62+
--cov-report lcov
63+
--cov-report annotate
64+
--cov=myproj tests/
65+
66+
You can specify output paths for reports. The output location for the XML, JSON, Markdown and LCOV
67+
report is a file. Where as the output location for the HTML and annotated source code reports are
68+
directories:
69+
70+
.. code-block:: bash
6771
6872
pytest --cov-report html:cov_html
69-
--cov-report xml:cov.xml
70-
--cov-report json:cov.json
71-
--cov-report markdown:cov.md
72-
--cov-report markdown-append:cov-append.md
73-
--cov-report lcov:cov.info
74-
--cov-report annotate:cov_annotate
75-
--cov=myproj tests/
76-
77-
The final report option can also suppress printing to the terminal::
73+
--cov-report xml:cov.xml
74+
--cov-report json:cov.json
75+
--cov-report markdown:cov.md
76+
--cov-report markdown-append:cov-append.md
77+
--cov-report lcov:cov.info
78+
--cov-report annotate:cov_annotate
79+
--cov=myproj tests/
80+
81+
Example for GitHub Actions with ``markdown-append``:
82+
83+
.. code-block:: bash
84+
85+
pytest --cov-report=markdown-append:${GITHUB_STEP_SUMMARY}.
86+
--cov=myproj tests/
87+
88+
To disable the default ``term`` report provide an empty report:
89+
90+
.. code-block:: bash
7891
7992
pytest --cov-report= --cov=myproj tests/
8093

0 commit comments

Comments
 (0)