summaryrefslogtreecommitdiff
path: root/coverage/control.py
diff options
context:
space:
mode:
authorStephen Finucane <stephen@that.guru>2016-11-18 14:47:35 +0000
committerStephen Finucane <stephen@that.guru>2016-11-18 14:47:35 +0000
commit6cf9adfcf0ed8d909242462f2289002856670487 (patch)
tree54fe6fd2b1111f9efd542348faeb7370b8df6c60 /coverage/control.py
parentda70bedd80b0c8ffe317fbe32f05f5bb51495b48 (diff)
downloadpython-coveragepy-issue-519.tar.gz
Read options from tox.iniissue-519
If coveragerc does not exist, setup.cfg does not exist or does not contain any coverage-related metadata, and no custom config file is provided, fall back to tox.ini. The syntax of tox.ini files is the same as that expected of setup.cfg files, namely: [coverage:{section}] Fixes: #519
Diffstat (limited to 'coverage/control.py')
-rw-r--r--coverage/control.py22
1 files changed, 14 insertions, 8 deletions
diff --git a/coverage/control.py b/coverage/control.py
index d920337..e658ef1 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')