Skip to content

Commit fd43e35

Browse files
committed
Finish up #967. Thanks, Bernát Gábor
1 parent 97997d2 commit fd43e35

File tree

4 files changed

+17
-1
lines changed

4 files changed

+17
-1
lines changed

CHANGES.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,13 @@ Unreleased
2828
decorated async functions (`issue 946`_). This is now fixed. Thanks, Kjell
2929
Braden.
3030

31+
- The :meth:`~coverage.Coverage.get_option` and
32+
:meth:`~coverage.Coverage.set_option` methods can now manipulate the
33+
``[paths]`` configuration setting. Thanks to Bernát Gábor for the fix for
34+
`issue 967`_.
35+
3136
.. _issue 946: https://github.com/nedbat/coveragepy/issues/946
37+
.. _issue 967: https://github.com/nedbat/coveragepy/issues/967
3238

3339

3440
.. _changes_504:

CONTRIBUTORS.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ Arcadiy Ivanov
2020
Aron Griffis
2121
Artem Dayneko
2222
Ben Finney
23+
Bernát Gábor
2324
Bill Hart
2425
Brandon Rhodes
2526
Brett Cannon

coverage/config.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,7 @@ def set_option(self, option_name, value):
421421
`value` is the new value for the option.
422422
423423
"""
424+
# Special-cased options.
424425
if option_name == "paths":
425426
self.paths = value
426427
return
@@ -451,6 +452,7 @@ def get_option(self, option_name):
451452
Returns the value of the option.
452453
453454
"""
455+
# Special-cased options.
454456
if option_name == "paths":
455457
return self.paths
456458

coverage/control.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,11 @@ def get_option(self, option_name):
367367
option name. For example, the ``branch`` option in the ``[run]``
368368
section of the config file would be indicated with `"run:branch"`.
369369
370-
Returns the value of the option.
370+
Returns the value of the option. The type depends on the option
371+
selected.
372+
373+
As a special case, an `option_name` of ``"paths"`` will return an
374+
OrderedDict with the entire ``[paths]`` section value.
371375
372376
.. versionadded:: 4.0
373377
@@ -394,6 +398,9 @@ def set_option(self, option_name, value):
394398
[run]
395399
branch = True
396400
401+
As a special case, an `option_name` of ``"paths"`` will replace the
402+
entire ``[paths]`` section. The value should be an OrderedDict.
403+
397404
.. versionadded:: 4.0
398405
399406
"""

0 commit comments

Comments
 (0)