summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2011-08-03 21:17:42 -0400
committerNed Batchelder <ned@nedbatchelder.com>2011-08-03 21:17:42 -0400
commit06e4538fca309d796d6e8f899bcad74146a96ff3 (patch)
treebdfdecfd0366b24cddf8ae0fe51c62f3cc6186fe /test
parent574d041fbbbbfda3fc4fcaff65629dd04c8eaa70 (diff)
downloadpython-coveragepy-git-06e4538fca309d796d6e8f899bcad74146a96ff3.tar.gz
You can include files in the Python installation, and they will be measured.
Diffstat (limited to 'test')
-rw-r--r--test/test_api.py27
1 files changed, 22 insertions, 5 deletions
diff --git a/test/test_api.py b/test/test_api.py
index 868a5441..48f10829 100644
--- a/test/test_api.py
+++ b/test/test_api.py
@@ -176,15 +176,11 @@ class ApiTest(CoverageTest):
def test_ignore_stdlib(self):
self.make_file("mymain.py", """\
- import mymod, colorsys
+ import colorsys
a = 1
hls = colorsys.rgb_to_hls(1.0, 0.5, 0.0)
""")
- self.make_file("mymod.py", """\
- fooey = 17
- """)
-
# Measure without the stdlib.
cov1 = coverage.coverage()
self.assertEqual(cov1.config.cover_pylib, False)
@@ -212,6 +208,27 @@ class ApiTest(CoverageTest):
_, statements, missing, _ = cov2.analysis("colorsys.py")
self.assertNotEqual(statements, missing)
+ def test_include_can_measure_stdlib(self):
+ self.make_file("mymain.py", """\
+ import colorsys, random
+ a = 1
+ r, g, b = [random.random() for _ in range(3)]
+ hls = colorsys.rgb_to_hls(r, g, b)
+ """)
+
+ # Measure without the stdlib, but include colorsys.
+ cov1 = coverage.coverage(cover_pylib=False, include=["*/colorsys.py"])
+ cov1.start()
+ self.import_local_file("mymain") # pragma: recursive coverage
+ cov1.stop() # pragma: recursive coverage
+
+ # some statements were marked executed in colorsys.py
+ _, statements, missing, _ = cov1.analysis("colorsys.py")
+ self.assertNotEqual(statements, missing)
+ # but none were in random.py
+ _, statements, missing, _ = cov1.analysis("random.py")
+ self.assertEqual(statements, missing)
+
def test_exclude_list(self):
cov = coverage.coverage()
cov.clear_exclude()