diff options
author | loic <loic@dachary.org> | 2016-12-16 13:29:18 +0100 |
---|---|---|
committer | loic <loic@dachary.org> | 2016-12-16 13:29:18 +0100 |
commit | cadcb4ca7a7d26589e5d42df1b4494636c39ed61 (patch) | |
tree | 346dc2c1d32ecccd3c765c0c2f07607026bc5c8c /coverage/config.py | |
parent | b33628b4918f47694e89526955cf83b9764f6562 (diff) | |
download | python-coveragepy-issue-265.tar.gz |
--source and --include are mutually exclusive #265issue-265
Add a sanity_check function to CoverageConfig to perform sanity checks
after configuration values have been collected from files, arguments
etc.
Raise an error if --source and --include are both set.
The config tests are amended because some of them have both source and
include set.
Based on the original patch from Nathan Land
close #265
Diffstat (limited to 'coverage/config.py')
-rw-r--r-- | coverage/config.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/coverage/config.py b/coverage/config.py index ad3efa9..f3e296c 100644 --- a/coverage/config.py +++ b/coverage/config.py @@ -383,6 +383,12 @@ class CoverageConfig(object): # If we get here, we didn't find the option. raise CoverageException("No such option: %r" % option_name) + def sanity_check(self): + if ((self.source is not None) and + (self.include is not None)): + raise CoverageException( + "--include and --source are mutually exclusive") + def read_coverage_config(config_file, **kwargs): """Read the coverage.py configuration. @@ -439,4 +445,6 @@ def read_coverage_config(config_file, **kwargs): # 4) from constructor arguments: config.from_args(**kwargs) + config.sanity_check() + return config_file, config |