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
commitc689ec0410d77f35cc14ce18281a4ef278b7de72 (patch)
treeea76748427535803f3a4704dd55e91e21e2a7162 /coverage/control.py
parent1dd172098e3681f32df2fded547992c837162a4e (diff)
downloadpython-coveragepy-git-c689ec0410d77f35cc14ce18281a4ef278b7de72.tar.gz
Read options from tox.ini
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 --HG-- branch : issue-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 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')