@@ -39,12 +39,13 @@ environment variable.
39
39
40
40
If ``.coveragerc `` doesn't exist and another file hasn't been specified, then
41
41
coverage.py will look for settings in other common configuration files, in this
42
- order: setup.cfg, tox.ini, or pyproject.toml. The first file found with
42
+ order: .coveragerc.toml, setup.cfg, tox.ini, or pyproject.toml. The first file found with
43
43
coverage.py settings will be used and other files won't be consulted.
44
44
45
- Coverage.py will read from "pyproject.toml" if TOML support is available,
45
+ Coverage.py will read from ".coveragerc.toml" and " pyproject.toml" if TOML support is available,
46
46
either because you are running on Python 3.11 or later, or because you
47
- installed with the ``toml `` extra (``pip install coverage[toml] ``).
47
+ installed with the ``toml `` extra (``pip install coverage[toml] ``). Both files
48
+ use the same ``[tool.coverage] `` section structure.
48
49
49
50
50
51
Syntax
@@ -136,6 +137,35 @@ Here's a sample configuration file, in each syntax:
136
137
[html]
137
138
directory = coverage_html_report
138
139
""",
140
+
141
+ coveragerc_toml=r"""
142
+ [tool.coverage.run]
143
+ branch = true
144
+
145
+ [tool.coverage.report]
146
+ # Regexes for lines to exclude from consideration
147
+ exclude_also = [
148
+ # Don't complain about missing debug-only code:
149
+ "def __repr__",
150
+ "if self\\.debug",
151
+
152
+ # Don't complain if tests don't hit defensive assertion code:
153
+ "raise AssertionError",
154
+ "raise NotImplementedError",
155
+
156
+ # Don't complain if non-runnable code isn't run:
157
+ "if 0:",
158
+ "if __name__ == .__main__.:",
159
+
160
+ # Don't complain about abstract methods, they aren't run:
161
+ "@(abc\\.)?abstractmethod",
162
+ ]
163
+
164
+ ignore_errors = true
165
+
166
+ [tool.coverage.html]
167
+ directory = "coverage_html_report"
168
+ """,
139
169
toml=r"""
140
170
[tool.coverage.run]
141
171
branch = true
@@ -198,6 +228,36 @@ Here's a sample configuration file, in each syntax:
198
228
[html]
199
229
directory = coverage_html_report
200
230
231
+ .. code-tab :: toml
232
+ :caption: .coveragerc.toml
233
+
234
+ [tool.coverage.run]
235
+ branch = true
236
+
237
+ [tool.coverage.report]
238
+ # Regexes for lines to exclude from consideration
239
+ exclude_also = [
240
+ # Don't complain about missing debug-only code:
241
+ "def __repr__",
242
+ "if self\\ .debug",
243
+
244
+ # Don't complain if tests don't hit defensive assertion code:
245
+ "raise AssertionError",
246
+ "raise NotImplementedError",
247
+
248
+ # Don't complain if non-runnable code isn't run:
249
+ "if 0:",
250
+ "if __name__ == .__main__.:",
251
+
252
+ # Don't complain about abstract methods, they aren't run:
253
+ "@(abc\\ .)?abstractmethod",
254
+ ]
255
+
256
+ ignore_errors = true
257
+
258
+ [tool.coverage.html]
259
+ directory = "coverage_html_report"
260
+
201
261
.. code-tab :: toml
202
262
:caption: pyproject.toml
203
263
0 commit comments