@@ -159,7 +159,13 @@ an editor and view the missing lines. However, it is easier to look at the HTML
159
159
report.
160
160
161
161
.. seealso ::
162
- * `pytest-cov’s documentation <https://pytest-cov.readthedocs.io/ >`_
162
+ * `covdefaults <https://pypi.org/project/covdefaults/ >`_: A coverage plugin
163
+ to provide sensible default settings
164
+ * `coverage-conditional-plugin
165
+ <https://pypi.org/project/coverage-conditional-plugin/> `_: Conditional
166
+ coverage based on any rules you define
167
+ * `Coverage.py regex pragmas
168
+ <https://nedbatchelder.com/blog/202507/coveragepy_regex_pragmas.html> `_
163
169
164
170
Generate HTML reports
165
171
~~~~~~~~~~~~~~~~~~~~~
@@ -304,12 +310,34 @@ Alternatively, this can also be configured for all occurrences:
304
310
`Configuration reference
305
311
<https://coverage.readthedocs.io/en/latest/config.html> `_
306
312
313
+ .. _coverage_tip :
314
+
315
+ .. tip ::
316
+ Many people exclude tests from test coverage: `omit tests
317
+ path:**/pyproject.toml
318
+ <https://github.com/search?q=omit+tests+path%3A**%2Fpyproject.toml&type=code> `_.
319
+ However, this is a bad idea. Your tests are real code, and the whole point of
320
+ test coverage is to give you information about your code. Why wouldn’t you
321
+ want this information about your tests?
322
+
323
+ You might say, *‘All my tests run the entire code, so it’s useless
324
+ information.’ * However, if you write a new test and copy an existing test for
325
+ it, changing only the execution but not the function name, only one of the
326
+ two test functions will be executed. And are you sure that every piece of
327
+ helper code in your test suite is still needed? Coverage would alert you to
328
+ this problem in both cases.
329
+
330
+ One argument against test coverage is that it artificially inflates the
331
+ reports. But you can easily exclude these files from the report with
332
+ `[report] skip_covered
333
+ <https://coverage.readthedocs.io/en/latest/config.html#report-skip-covered> `_.
334
+
307
335
Extensions
308
336
----------
309
337
310
338
In `Coverage.py plugins
311
- <https://gist.github.com/nedbat/2e9dbf7f33b1e0e857368af5c5d06202> `_ you will also
312
- find a number of extensions for Coverage.
339
+ <https://gist.github.com/nedbat/2e9dbf7f33b1e0e857368af5c5d06202> `_, you will
340
+ also find other extensions for Coverage.
313
341
314
342
.. _coverage-github-actions :
315
343
0 commit comments