From 7cd0901a6082aae0d39f2faa675533325e95a537 Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Wed, 29 Apr 2009 21:50:23 -0400 Subject: Python stdlib is now not measured by default. If needed, turn it on with the -L switch. --- test/test_coverage.py | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 'test') 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): -- cgit v1.2.1