Skip to content

Commit 7565729

Browse files
Add the new config parameter for show_configs function and update the docs
1 parent 4d2ec95 commit 7565729

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
@@ -657,6 +629,16 @@ equivalent when combining data from different machines:
657629
/jenkins/build/*/src
658630
c:\myproj\src
659631
632+
.. code-tab:: toml
633+
:caption: .coveragerc.toml
634+
635+
[tool.coverage.paths]
636+
source = [
637+
"src/",
638+
"/jenkins/build/*/src",
639+
"c:\\myproj\\src",
640+
]
641+
660642
.. code-tab:: toml
661643
:caption: pyproject.toml
662644

@@ -676,7 +658,7 @@ equivalent when combining data from different machines:
676658
/jenkins/build/*/src
677659
c:\myproj\src
678660
679-
.. [[[end]]] (sum: oHSl8SGiMT)
661+
.. [[[end]]] (sum: QLgJoxGH3G)
680662
681663
682664
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
@@ -144,6 +144,14 @@ all of them by adding a regex to the exclusion list:
144144
exclude_also =
145145
def __repr__
146146

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

@@ -159,7 +167,7 @@ all of them by adding a regex to the exclusion list:
159167
exclude_also =
160168
def __repr__
161169

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

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

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

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

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

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

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

346-
.. [[[end]]] (sum: xG6Bmtmh06)
384+
.. [[[end]]] (sum: eg9c8WbMqW)
347385
348386
The first regex matches a specific except line followed by a specific function
349387
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)