@@ -39,12 +39,13 @@ environment variable.
3939
4040If ``.coveragerc `` doesn't exist and another file hasn't been specified, then
4141coverage.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
4343coverage.py settings will be used and other files won't be consulted.
4444
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,
4646either 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.
4849
4950
5051Syntax
@@ -136,6 +137,35 @@ Here's a sample configuration file, in each syntax:
136137 [html]
137138 directory = coverage_html_report
138139 """,
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+ """,
139169 toml=r"""
140170 [tool.coverage.run]
141171 branch = true
@@ -198,6 +228,36 @@ Here's a sample configuration file, in each syntax:
198228 [html]
199229 directory = coverage_html_report
200230
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+
201261 .. code-tab :: toml
202262 :caption: pyproject.toml
203263
0 commit comments