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
commit7cd0901a6082aae0d39f2faa675533325e95a537 (patch)
treec942b636d69138aff69754269e6bc4ed9f125acc /test/test_coverage.py
parent06b74ffa1a8b47672e5c948783a60cf21c106742 (diff)
downloadpython-coveragepy-git-7cd0901a6082aae0d39f2faa675533325e95a537.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 f9f4c55f..cc30ecda 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):