summaryrefslogtreecommitdiff
path: root/coverage/control.py
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2009-11-28 16:59:58 -0500
committerNed Batchelder <ned@nedbatchelder.com>2009-11-28 16:59:58 -0500
commit81a363edf04f614af736ce32d79791a210e1e1fd (patch)
tree31216c347f65cc00a6f4a403b4d6abf63c7cf375 /coverage/control.py
parentbe8afd0bc3f173926fc751c50f9975543f301a91 (diff)
downloadpython-coveragepy-git-81a363edf04f614af736ce32d79791a210e1e1fd.tar.gz
Read .coveragerc by default.
--HG-- branch : config
Diffstat (limited to 'coverage/control.py')
-rw-r--r--coverage/control.py23
1 files changed, 18 insertions, 5 deletions
diff --git a/coverage/control.py b/coverage/control.py
index 349ff307..6e18b058 100644
--- a/coverage/control.py
+++ b/coverage/control.py
@@ -30,7 +30,7 @@ class coverage(object):
"""
def __init__(self, data_file=None, data_suffix=False, cover_pylib=None,
- auto_data=False, timid=None, branch=None):
+ auto_data=False, timid=None, branch=None, config_file=True):
"""
`data_file` is the base name of the data file to use, defaulting to
".coverage". `data_suffix` is appended to `data_file` to create the
@@ -51,14 +51,26 @@ class coverage(object):
If `branch` is true, then branch coverage will be measured in addition
to the usual statement coverage.
+
+ `config_file` determines what config file to read. If it is a string,
+ it is the name of the config file to read. If it is True, then a
+ standard file is read (".coveragerc"). If it is False, then no file is
+ read.
"""
from coverage import __version__
-
+
+ # Build our configuration from a number of sources.
self.config = CoverageConfig()
+ if config_file:
+ if config_file is True:
+ config_file = ".coveragerc"
+ self.config.from_file(config_file)
self.config.from_environment('COVERAGE_OPTIONS')
- self.config.from_args(cover_pylib=cover_pylib, timid=timid, branch=branch)
-
+ self.config.from_args(
+ cover_pylib=cover_pylib, timid=timid, branch=branch
+ )
+
self.auto_data = auto_data
self.exclude_re = ""
@@ -67,7 +79,8 @@ class coverage(object):
self.file_locator = FileLocator()
self.collector = Collector(
- self._should_trace, timid=self.config.timid, branch=self.config.branch
+ self._should_trace, timid=self.config.timid,
+ branch=self.config.branch
)
# Create the data file.