diff options
author | Ned Batchelder <ned@nedbatchelder.com> | 2017-10-24 04:47:01 -0400 |
---|---|---|
committer | Ned Batchelder <ned@nedbatchelder.com> | 2017-10-24 04:47:01 -0400 |
commit | f5587814d1aa983ad995b2c1acc391f6251ceda0 (patch) | |
tree | dc8e73d0445d2ab1ba760a478012d50159bae76b /tests/test_api.py | |
parent | 9c791748dc97d33cf0f5f2205e53764df9d19241 (diff) | |
download | python-coveragepy-f5587814d1aa983ad995b2c1acc391f6251ceda0.tar.gz |
Belatedly add a test for #541, so we can fix #265 for real
Diffstat (limited to 'tests/test_api.py')
-rw-r--r-- | tests/test_api.py | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/test_api.py b/tests/test_api.py index 39e3122..5618458 100644 --- a/tests/test_api.py +++ b/tests/test_api.py @@ -446,6 +446,32 @@ class ApiTest(CoverageTest): self.assertNotIn("module-not-imported", err) self.assertNotIn("no-data-collected", err) + def test_source_and_include_dont_conflict(self): + # A bad fix made this case fail: https://bitbucket.org/ned/coveragepy/issues/541 + self.make_file("a.py", "import b\na = 1") + self.make_file("b.py", "b = 1") + self.make_file(".coveragerc", """\ + [run] + source = . + """) + + # Just like: coverage run a.py + cov = coverage.Coverage() + self.start_import_stop(cov, "a") + cov.save() + + # Run the equivalent of: coverage report --include=b.py + cov = coverage.Coverage(include=["b.py"]) + cov.load() + # There should be no exception. At one point, report() threw: + # CoverageException: --include and --source are mutually exclusive + cov.report() + self.assertEqual(self.stdout(), textwrap.dedent("""\ + Name Stmts Miss Cover + --------------------------- + b.py 1 0 100% + """)) + class NamespaceModuleTest(UsingModulesMixin, CoverageTest): """Test PEP-420 namespace modules.""" |