summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2017-10-24 04:47:01 -0400
committerNed Batchelder <ned@nedbatchelder.com>2017-10-24 04:47:01 -0400
commit9242d96f2be40ecc556f8cf3cb9fb6fea7d4ea02 (patch)
tree6899fbf829ac33c04e57c8fdbfb14e9eca7b41aa /tests
parent6e569749d2a072f6e962ff6055256a3ab41e6247 (diff)
downloadpython-coveragepy-git-9242d96f2be40ecc556f8cf3cb9fb6fea7d4ea02.tar.gz
Belatedly add a test for #541, so we can fix #265 for real
Diffstat (limited to 'tests')
-rw-r--r--tests/test_api.py26
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/test_api.py b/tests/test_api.py
index 39e3122d..56184586 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."""