diff options
author | Ned Batchelder <ned@nedbatchelder.com> | 2014-11-27 07:38:40 -0500 |
---|---|---|
committer | Ned Batchelder <ned@nedbatchelder.com> | 2014-11-27 07:38:40 -0500 |
commit | c44bbcd1d86e6c4192988f20319d9e3c94e263b6 (patch) | |
tree | 9218d553861beac5f7030dfc645c708e29c8d301 /coverage/control.py | |
parent | 0429009cf349d69b9b63bf2dc30755590067b510 (diff) | |
download | python-coveragepy-git-c44bbcd1d86e6c4192988f20319d9e3c94e263b6.tar.gz |
Give error messages if an explicitly provided rcfile can't be read.
Diffstat (limited to 'coverage/control.py')
-rw-r--r-- | coverage/control.py | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/coverage/control.py b/coverage/control.py index 815c16b9..6aa06da8 100644 --- a/coverage/control.py +++ b/coverage/control.py @@ -94,20 +94,20 @@ class Coverage(object): # 1: defaults: self.config = CoverageConfig() - # 2: from the .coveragerc or setup.cfg file: + # 2: from the rcfile, .coveragerc or setup.cfg file: if config_file: - did_read_rc = should_read_setupcfg = False - if config_file is True: + did_read_rc = False + specified_file = (config_file is not True) + if not specified_file: config_file = ".coveragerc" - should_read_setupcfg = True - try: - did_read_rc = self.config.from_file(config_file) - except ValueError as err: - raise CoverageException( - "Couldn't read config file %s: %s" % (config_file, err) - ) - - if not did_read_rc and should_read_setupcfg: + + did_read_rc = self.config.from_file(config_file) + + if not did_read_rc: + if specified_file: + raise CoverageException( + "Couldn't read %r as a config file" % config_file + ) self.config.from_file("setup.cfg", section_prefix="coverage:") # 3: from environment variables: |