diff options
-rw-r--r-- | coverage/config.py | 8 | ||||
-rw-r--r-- | tests/test_cmdline.py | 6 | ||||
-rw-r--r-- | tests/test_config.py | 2 |
3 files changed, 13 insertions, 3 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 diff --git a/tests/test_cmdline.py b/tests/test_cmdline.py index 3b982eb..3b674de 100644 --- a/tests/test_cmdline.py +++ b/tests/test_cmdline.py @@ -16,7 +16,7 @@ import coverage.cmdline from coverage import env from coverage.config import CoverageConfig from coverage.data import CoverageData, CoverageDataFiles -from coverage.misc import ExceptionDuringRun +from coverage.misc import CoverageException, ExceptionDuringRun from tests.coveragetest import CoverageTest, OK, ERR @@ -459,6 +459,10 @@ class CmdLineTest(BaseCmdLineTest): .save() """) + def test_bad_run_args_with_both_source_and_include(self): + with self.assertRaisesRegex(CoverageException, 'mutually exclusive'): + self.command_line("run --include=pre1,pre2 --source=lol,wut foo.py", ret=ERR) + def test_bad_concurrency(self): self.command_line("run --concurrency=nothing", ret=ERR) out = self.stdout() diff --git a/tests/test_config.py b/tests/test_config.py index 6cb5e46..2aa592b 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -239,7 +239,6 @@ class ConfigFileTest(CoverageTest): branch = 1 cover_pylib = TRUE parallel = on - include = a/ , b/ concurrency = thread source = myapp plugins = @@ -329,7 +328,6 @@ class ConfigFileTest(CoverageTest): self.assertEqual(cov.get_exclude_list(), ["if 0:", r"pragma:?\s+no cover", "another_tab"]) self.assertTrue(cov.config.ignore_errors) - self.assertEqual(cov.config.include, ["a/", "b/"]) self.assertEqual(cov.config.omit, ["one", "another", "some_more", "yet_more"]) self.assertEqual(cov.config.precision, 3) |