diff options
author | Ned Batchelder <nedbat@gmail.com> | 2016-11-19 21:24:49 +0000 |
---|---|---|
committer | Ned Batchelder <nedbat@gmail.com> | 2016-11-19 21:24:49 +0000 |
commit | 0fcc12cc8be534229eaf6f9f828259ac24fc1742 (patch) | |
tree | 6888c2ae6b2c5cfddf54f90bedfa81082cc9221d /coverage/control.py | |
parent | 94c8021df549b99418b3bca102c03c65924740b4 (diff) | |
parent | c689ec0410d77f35cc14ce18281a4ef278b7de72 (diff) | |
download | python-coveragepy-git-0fcc12cc8be534229eaf6f9f828259ac24fc1742.tar.gz |
Merged in stephenfin/coverage.py/issue-519 (pull request #92)
Read options from tox.ini
Diffstat (limited to 'coverage/control.py')
-rw-r--r-- | coverage/control.py | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/coverage/control.py b/coverage/control.py index d9203379..e658ef1b 100644 --- a/coverage/control.py +++ b/coverage/control.py @@ -134,10 +134,8 @@ class Coverage(object): # 1: defaults: self.config = CoverageConfig() - # 2: from the rcfile, .coveragerc or setup.cfg file: + # 2: from the rcfile, .coveragerc, .tox or setup.cfg file: if config_file: - # pylint: disable=redefined-variable-type - did_read_rc = False # Some API users were specifying ".coveragerc" to mean the same as # True, so make it so. if config_file == ".coveragerc": @@ -147,14 +145,22 @@ class Coverage(object): config_file = ".coveragerc" self.config_file = config_file - did_read_rc = self.config.from_file(config_file) + for fname, prefix in [(config_file, ""), + ("setup.cfg", "coverage:"), + ("tox.ini", "coverage:")]: + config_read = self.config.from_file(fname, + section_prefix=prefix) + print('config read?') + print(config_read) + is_config_file = fname == config_file - if not did_read_rc: - if specified_file: + if not config_read and is_config_file and specified_file: raise CoverageException( - "Couldn't read '%s' as a config file" % config_file + "Couldn't read '%s' as a config file" % fname ) - self.config.from_file("setup.cfg", section_prefix="coverage:") + + if config_read: + break # 3: from environment variables: env_data_file = os.environ.get('COVERAGE_FILE') |