summaryrefslogtreecommitdiff
path: root/coverage/control.py
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2015-08-02 12:51:14 -0400
committerNed Batchelder <ned@nedbatchelder.com>2015-08-02 12:51:14 -0400
commit532ca16b158b8e8ffb8857237a801ec7e641bf46 (patch)
tree0cfbeedffe34378a1f5149a0bf05362dc8b3739b /coverage/control.py
parent959447537d8d8f4d91f5bf25b810e49bdaffddf6 (diff)
downloadpython-coveragepy-git-532ca16b158b8e8ffb8857237a801ec7e641bf46.tar.gz
Change the coverage.config item-access syntax to a real method call.
The square brackets were too cute, and I couldn't figure out how to document them anyway!
Diffstat (limited to 'coverage/control.py')
-rw-r--r--coverage/control.py35
1 files changed, 35 insertions, 0 deletions
diff --git a/coverage/control.py b/coverage/control.py
index ad3c1bdf..02fe66bf 100644
--- a/coverage/control.py
+++ b/coverage/control.py
@@ -596,6 +596,41 @@ class Coverage(object):
msg = "[%d] %s" % (os.getpid(), msg)
sys.stderr.write("Coverage.py warning: %s\n" % msg)
+ def get_option(self, option_name):
+ """Get an option from the configuration.
+
+ `option_name` is a colon-separated string indicating the section and
+ option name. For example, the ``branch`` option in the ``[run]``
+ section of the config file would be indicated with `"run:branch"`.
+
+ Returns the value of the option.
+
+ """
+ return self.config.get_option(option_name)
+
+ def set_option(self, option_name, value):
+ """Set an option in the configuration.
+
+ `option_name` is a colon-separated string indicating the section and
+ option name. For example, the ``branch`` option in the ``[run]``
+ section of the config file would be indicated with `"run:branch"`.
+
+ `value` is the new value for the option. This should be a Python
+ value where appropriate. For example, use True for booleans, not the
+ string ``"True"``.
+
+ As an example, calling::
+
+ cov.set_option("run:branch", True)
+
+ has the same effect as this configuration file:
+
+ [run]
+ branch = True
+
+ """
+ self.config.set_option(option_name, value)
+
def use_cache(self, usecache):
"""Obsolete method."""
self._init()