diff options
author | Ned Batchelder <ned@nedbatchelder.com> | 2010-05-15 19:47:14 -0400 |
---|---|---|
committer | Ned Batchelder <ned@nedbatchelder.com> | 2010-05-15 19:47:14 -0400 |
commit | 4fb69b6c13c00bba910afe9d6beade673f4e4386 (patch) | |
tree | eb8a25de40952b9ed98a66e6c82caf9805ffac08 /test/test_api.py | |
parent | 128e1985c1d0f958dfda551f92fc858c1989777f (diff) | |
download | python-coveragepy-git-4fb69b6c13c00bba910afe9d6beade673f4e4386.tar.gz |
Hook up omit and include to the run command. Test the new cmdline behavior and run behavior.
Diffstat (limited to 'test/test_api.py')
-rw-r--r-- | test/test_api.py | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/test/test_api.py b/test/test_api.py index 4c491366..4580645b 100644 --- a/test/test_api.py +++ b/test/test_api.py @@ -271,3 +271,72 @@ class ApiTest(CoverageTest): cov = coverage.coverage() cov.erase() cov.report() + +class OmitIncludeTest(CoverageTest): + def test_nothing_specified(self): + self.make_file("a.py", """\ + a = 1 + """) + self.make_file("b.py", """\ + import a + b = 1 + """) + + cov = coverage.coverage() + cov.start() + self.import_module("b") + cov.stop() + lines = cov.data.summary() + self.assertEqual(lines['a.py'], 1) + self.assertEqual(lines['b.py'], 2) + + def test_include(self): + self.make_file("a.py", """\ + a = 1 + """) + self.make_file("b.py", """\ + import a + b = 1 + """) + + cov = coverage.coverage(include_prefixes=["a"]) + cov.start() + self.import_module("b") + cov.stop() + lines = cov.data.summary() + self.assertEqual(lines['a.py'], 1) + self.assert_('b.py' not in lines) + + def test_omit(self): + self.make_file("a.py", """\ + a = 1 + """) + self.make_file("b.py", """\ + import a + b = 1 + """) + + cov = coverage.coverage(omit_prefixes=["a"]) + cov.start() + self.import_module("b") + cov.stop() + lines = cov.data.summary() + self.assert_('a.py' not in lines) + self.assertEqual(lines['b.py'], 2) + + def test_omit_and_include(self): + self.make_file("aa.py", """\ + a = 1 + """) + self.make_file("ab.py", """\ + import aa + b = 1 + """) + + cov = coverage.coverage(include_prefixes=["a"], omit_prefixes=["aa"]) + cov.start() + self.import_module("ab") + cov.stop() + lines = cov.data.summary() + self.assert_('aa.py' not in lines) + self.assertEqual(lines['ab.py'], 2) |