summaryrefslogtreecommitdiff
path: root/test/test_parser.py
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2009-11-21 13:10:10 -0500
committerNed Batchelder <ned@nedbatchelder.com>2009-11-21 13:10:10 -0500
commitb8c23d479ae5a0da883a59d433193533c7ef63e4 (patch)
treed7c40cace860a55a91b1b9c20de0bc664f769cc9 /test/test_parser.py
parent9ce4e0e787c7e8f028a2c2f56c50b6d8f663e88c (diff)
downloadpython-coveragepy-git-b8c23d479ae5a0da883a59d433193533c7ef63e4.tar.gz
Don't count branches to excluded code. Tests don't pass yet.
Diffstat (limited to 'test/test_parser.py')
-rw-r--r--test/test_parser.py31
1 files changed, 29 insertions, 2 deletions
diff --git a/test/test_parser.py b/test/test_parser.py
index 3d5726de..7a9ff066 100644
--- a/test/test_parser.py
+++ b/test/test_parser.py
@@ -16,7 +16,7 @@ class ParserTest(CoverageTest):
def parse_source(self, text):
"""Parse `text` as source, and return the `CodeParser` used."""
text = textwrap.dedent(text)
- cp = CodeParser(text)
+ cp = CodeParser(text, exclude="nocover")
cp.parse_source()
return cp
@@ -52,4 +52,31 @@ class ParserTest(CoverageTest):
self.assertEqual(cp.exit_counts(), {
1: 1, 2:1, 3:1, 4:1, 5:1, 6:1, 7:1, 8:1, 9:1
})
- \ No newline at end of file
+
+ def test_missing_branch_to_excluded_code(self):
+ cp = self.parse_source("""\
+ if fooey:
+ a = 2
+ else: # nocover
+ a = 4
+ b = 5
+ """)
+ self.assertEqual(cp.exit_counts(), { 1:1, 2:1, 5:1 })
+ cp = self.parse_source("""\
+ def foo():
+ if fooey:
+ a = 3
+ else:
+ a = 5
+ b = 6
+ """)
+ self.assertEqual(cp.exit_counts(), { 1:1, 2:2, 3:1, 5:1, 6:1 })
+ cp = self.parse_source("""\
+ def foo():
+ if fooey:
+ a = 3
+ else: # nocover
+ a = 5
+ b = 6
+ """)
+ self.assertEqual(cp.exit_counts(), { 1:13, 2:1, 6:1 })