Skip to content

Commit 5f4e5b0

Browse files
Add the new config parameter for show_configs function and update the docs
1 parent c584e0d commit 5f4e5b0

File tree

7 files changed

+98
-39
lines changed

7 files changed

+98
-39
lines changed

doc/cmd.rst

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,12 @@ file:
322322
[run]
323323
disable_warnings = no-data-collected
324324

325+
.. code-tab:: toml
326+
:caption: .coveragerc.toml
327+
328+
[tool.coverage.run]
329+
disable_warnings = ["no-data-collected"]
330+
325331
.. code-tab:: toml
326332
:caption: pyproject.toml
327333

@@ -334,7 +340,7 @@ file:
334340
[coverage:run]
335341
disable_warnings = no-data-collected
336342

337-
.. [[[end]]] (sum: SJKFvPoXO2)
343+
.. [[[end]]] (sum: CZaDzmXkEi)
338344
339345
340346
.. _cmd_datafile:

doc/cog_helpers.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ def show_configs(ini, toml):
7575
The equivalence is checked for accuracy, and the process fails if there's
7676
a mismatch.
7777
78-
A three-tabbed box will be produced.
78+
A four-tabbed box will be produced.
7979
"""
8080
ini, ini_vals = _read_config(ini, "covrc")
8181
toml, toml_vals = _read_config(toml, "covrc.toml")
@@ -88,6 +88,7 @@ def show_configs(ini, toml):
8888
print(".. tabs::\n")
8989
for name, syntax, text in [
9090
(".coveragerc", "ini", ini),
91+
(".coveragerc.toml", "toml", toml),
9192
("pyproject.toml", "toml", toml),
9293
("setup.cfg or tox.ini", "ini", ini2),
9394
]:

doc/config.rst

Lines changed: 12 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -138,34 +138,6 @@ Here's a sample configuration file, in each syntax:
138138
directory = coverage_html_report
139139
""",
140140
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-
""",
169141
toml=r"""
170142
[tool.coverage.run]
171143
branch = true
@@ -317,7 +289,7 @@ Here's a sample configuration file, in each syntax:
317289
[coverage:html]
318290
directory = coverage_html_report
319291

320-
.. [[[end]]] (sum: HU1Z62mvRK)
292+
.. [[[end]]] (sum: EQ1Fn4BHJk)
321293
322294
323295
The specific configuration settings are described below. Many sections and
@@ -636,6 +608,16 @@ equivalent when combining data from different machines:
636608
/jenkins/build/*/src
637609
c:\myproj\src
638610
611+
.. code-tab:: toml
612+
:caption: .coveragerc.toml
613+
614+
[tool.coverage.paths]
615+
source = [
616+
"src/",
617+
"/jenkins/build/*/src",
618+
"c:\\myproj\\src",
619+
]
620+
639621
.. code-tab:: toml
640622
:caption: pyproject.toml
641623

@@ -655,7 +637,7 @@ equivalent when combining data from different machines:
655637
/jenkins/build/*/src
656638
c:\myproj\src
657639
658-
.. [[[end]]] (sum: oHSl8SGiMT)
640+
.. [[[end]]] (sum: QLgJoxGH3G)
659641
660642
661643
The names of the entries ("source" in this example) are ignored, you may choose

doc/contexts.rst

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,12 @@ The ``[run] dynamic_context`` setting has only one option now. Set it to
9696
[run]
9797
dynamic_context = test_function
9898

99+
.. code-tab:: toml
100+
:caption: .coveragerc.toml
101+
102+
[tool.coverage.run]
103+
dynamic_context = "test_function"
104+
99105
.. code-tab:: toml
100106
:caption: pyproject.toml
101107

@@ -108,7 +114,7 @@ The ``[run] dynamic_context`` setting has only one option now. Set it to
108114
[coverage:run]
109115
dynamic_context = test_function
110116

111-
.. [[[end]]] (sum: dZTDYjHw71)
117+
.. [[[end]]] (sum: oHx7GVdhqU)
112118
113119
Each test function you run will be considered a separate dynamic context, and
114120
coverage data will be segregated for each. A test function is any function

doc/excluding.rst

Lines changed: 41 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,14 @@ all of them by adding a regex to the exclusion list:
143143
exclude_also =
144144
def __repr__
145145

146+
.. code-tab:: toml
147+
:caption: .coveragerc.toml
148+
149+
[tool.coverage.report]
150+
exclude_also = [
151+
"def __repr__",
152+
]
153+
146154
.. code-tab:: toml
147155
:caption: pyproject.toml
148156

@@ -158,7 +166,7 @@ all of them by adding a regex to the exclusion list:
158166
exclude_also =
159167
def __repr__
160168

161-
.. [[[end]]] (sum: 8+cOvxKPvv)
169+
.. [[[end]]] (sum: 4lYsdpcbf/)
162170
163171
For example, here's a list of exclusions I've used:
164172

@@ -214,6 +222,23 @@ For example, here's a list of exclusions I've used:
214222
class .*\bProtocol\):
215223
@(abc\.)?abstractmethod
216224

225+
.. code-tab:: toml
226+
:caption: .coveragerc.toml
227+
228+
[tool.coverage.report]
229+
exclude_also = [
230+
'def __repr__',
231+
'if self.debug:',
232+
'if settings.DEBUG',
233+
'raise AssertionError',
234+
'raise NotImplementedError',
235+
'if 0:',
236+
'if __name__ == .__main__.:',
237+
'if TYPE_CHECKING:',
238+
'class .*\bProtocol\):',
239+
'@(abc\.)?abstractmethod',
240+
]
241+
217242
.. code-tab:: toml
218243
:caption: pyproject.toml
219244

@@ -247,7 +272,7 @@ For example, here's a list of exclusions I've used:
247272
class .*\bProtocol\):
248273
@(abc\.)?abstractmethod
249274

250-
.. [[[end]]] (sum: ZQsgnt0nES)
275+
.. [[[end]]] (sum: +D/FLd6oVC)
251276
252277
The :ref:`config_report_exclude_also` option adds regexes to the built-in
253278
default list so that you can add your own exclusions. The older
@@ -317,6 +342,19 @@ Here are some examples:
317342
; 3. A pragma comment that excludes an entire file:
318343
\A(?s:.*# pragma: exclude file.*)\Z
319344

345+
.. code-tab:: toml
346+
:caption: .coveragerc.toml
347+
348+
[tool.coverage.report]
349+
exclude_also = [
350+
# 1. Exclude an except clause of a specific form:
351+
'except ValueError:\n\s*assume\(False\)',
352+
# 2. Comments to turn coverage on and off:
353+
'no cover: start(?s:.)*?no cover: stop',
354+
# 3. A pragma comment that excludes an entire file:
355+
'\A(?s:.*# pragma: exclude file.*)\Z',
356+
]
357+
320358
.. code-tab:: toml
321359
:caption: pyproject.toml
322360

@@ -342,7 +380,7 @@ Here are some examples:
342380
; 3. A pragma comment that excludes an entire file:
343381
\A(?s:.*# pragma: exclude file.*)\Z
344382

345-
.. [[[end]]] (sum: xG6Bmtmh06)
383+
.. [[[end]]] (sum: eg9c8WbMqW)
346384
347385
The first regex matches a specific except line followed by a specific function
348386
call. Both lines must be present for the exclusion to take effect. Note that

doc/plugins.rst

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,12 @@ a coverage.py plug-in called ``something.plugin``.
7171
plugins =
7272
something.plugin
7373

74+
.. code-tab:: toml
75+
:caption: .coveragerc.toml
76+
77+
[tool.coverage.run]
78+
plugins = [ "something.plugin" ]
79+
7480
.. code-tab:: toml
7581
:caption: pyproject.toml
7682

@@ -84,7 +90,7 @@ a coverage.py plug-in called ``something.plugin``.
8490
plugins =
8591
something.plugin
8692

87-
.. [[[end]]] (sum: boZjI9S8MZ)
93+
.. [[[end]]] (sum: +V9pwwXF47)
8894
8995
#. If the plug-in needs its own configuration, you can add those settings in
9096
the .coveragerc file in a section named for the plug-in:
@@ -113,6 +119,13 @@ a coverage.py plug-in called ``something.plugin``.
113119
option1 = True
114120
option2 = abc.foo
115121

122+
.. code-tab:: toml
123+
:caption: .coveragerc.toml
124+
125+
[tool.coverage.something.plugin]
126+
option1 = true
127+
option2 = "abc.foo"
128+
116129
.. code-tab:: toml
117130
:caption: pyproject.toml
118131

@@ -127,7 +140,7 @@ a coverage.py plug-in called ``something.plugin``.
127140
option1 = True
128141
option2 = abc.foo
129142

130-
.. [[[end]]] (sum: tpARXb5/bH)
143+
.. [[[end]]] (sum: woHFW9mOUC)
131144
132145
Check the documentation for the plug-in for details on the options it takes.
133146

doc/source.rst

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,19 @@ current directory:
114114
# omit this single file
115115
utils/tirefire.py
116116

117+
.. code-tab:: toml
118+
:caption: .coveragerc.toml
119+
120+
[tool.coverage.run]
121+
omit = [
122+
# omit anything in a .local directory anywhere
123+
"*/.local/*",
124+
# omit everything in /usr
125+
"/usr/*",
126+
# omit this single file
127+
"utils/tirefire.py",
128+
]
129+
117130
.. code-tab:: toml
118131
:caption: pyproject.toml
119132

@@ -139,7 +152,7 @@ current directory:
139152
# omit this single file
140153
utils/tirefire.py
141154

142-
.. [[[end]]] (sum: hK0nQ8wMeg)
155+
.. [[[end]]] (sum: lKoRbHzA05)
143156
144157
The ``source``, ``include``, and ``omit`` values all work together to determine
145158
the source that will be measured.

0 commit comments

Comments
 (0)