diff options
author | Ned Batchelder <ned@nedbatchelder.com> | 2011-08-03 21:17:42 -0400 |
---|---|---|
committer | Ned Batchelder <ned@nedbatchelder.com> | 2011-08-03 21:17:42 -0400 |
commit | 02c995d45f7114df741bbd644b5810645df98740 (patch) | |
tree | 353dc0ae9a8a46df55e379561d1bf97d66d50e5a /test/test_api.py | |
parent | b16b0b8bb74367803694ebfad1cbdb4ab7969a96 (diff) | |
download | python-coveragepy-02c995d45f7114df741bbd644b5810645df98740.tar.gz |
You can include files in the Python installation, and they will be measured.
Diffstat (limited to 'test/test_api.py')
-rw-r--r-- | test/test_api.py | 27 |
1 files changed, 22 insertions, 5 deletions
diff --git a/test/test_api.py b/test/test_api.py index 868a544..48f1082 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() |