diff options
-rw-r--r-- | coverage/config.py | 11 | ||||
-rw-r--r-- | coverage/control.py | 23 |
2 files changed, 21 insertions, 13 deletions
diff --git a/coverage/config.py b/coverage/config.py index ca7bab61..0596cc04 100644 --- a/coverage/config.py +++ b/coverage/config.py @@ -35,11 +35,6 @@ class CoverageConfig(object): if cp.has_option('run', 'branch'): self.branch = cp.getboolean('run', 'branch') if cp.has_option('report', 'exclude'): - self.exclude_list = filter(None, cp.get('report', 'exclude').split('\n')) - - -if __name__ == '__main__': - cc = CoverageConfig() - cc.from_file(".coveragerc", ".coverage.ini") - import pdb;pdb.set_trace() - print cc + # Exclude is a list of lines, leave out the blank ones. + exclude_list = cp.get('report', 'exclude') + self.exclude_list = filter(None, exclude_list.split('\n')) 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. |