summaryrefslogtreecommitdiff
path: root/test/test_coverage.py
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2009-04-29 21:50:23 -0400
committerNed Batchelder <ned@nedbatchelder.com>2009-04-29 21:50:23 -0400
commit62ab88a1a06e712427c1f57c561e2afb7aa7b21d (patch)
tree8c076d984bbca191d14b2d780caaab85a1e1a78d /test/test_coverage.py
parent89d2c9dc416949ca9e3181f8367de1e5dd8e3fde (diff)
downloadpython-coveragepy-62ab88a1a06e712427c1f57c561e2afb7aa7b21d.tar.gz
Python stdlib is now not measured by default. If needed, turn it on with the -L switch.coverage-3.0b2
Diffstat (limited to 'test/test_coverage.py')
-rw-r--r--test/test_coverage.py38
1 files changed, 38 insertions, 0 deletions
diff --git a/test/test_coverage.py b/test/test_coverage.py
index f9f4c55..cc30ecd 100644
--- a/test/test_coverage.py
+++ b/test/test_coverage.py
@@ -1688,6 +1688,44 @@ class ApiTest(CoverageTest):
filename, _, _, _ = cov.analysis(sys.modules["mymod"])
self.assertEqual(os.path.basename(filename), "mymod.py")
+ def testIgnoreStdLib(self):
+ self.makeFile("mymain", """\
+ import mymod, colorsys
+ a = 1
+ hls = colorsys.rgb_to_hls(1.0, 0.5, 0.0)
+ """)
+
+ self.makeFile("mymod", """\
+ fooey = 17
+ """)
+
+ # Measure without the stdlib.
+ cov1 = coverage.coverage()
+ self.assertEqual(cov1.cover_stdlib, False)
+ cov1.start()
+ self.importModule("mymain")
+ cov1.stop()
+
+ # some statements were marked executed in mymain.py
+ _, statements, missing, _ = cov1.analysis("mymain.py")
+ self.assertNotEqual(statements, missing)
+ # but none were in colorsys.py
+ _, statements, missing, _ = cov1.analysis("colorsys.py")
+ self.assertEqual(statements, missing)
+
+ # Measure with the stdlib.
+ cov2 = coverage.coverage()
+ cov2.cover_stdlib = True
+ cov2.start()
+ self.importModule("mymain")
+ cov2.stop()
+
+ # some statements were marked executed in mymain.py
+ _, statements, missing, _ = cov2.analysis("mymain.py")
+ self.assertNotEqual(statements, missing)
+ # and some were marked executed in colorsys.py
+ _, statements, missing, _ = cov2.analysis("colorsys.py")
+ self.assertNotEqual(statements, missing)
class ProcessTest(CoverageTest):