summaryrefslogtreecommitdiff
path: root/tests/test_parser.py
diff options
context:
space:
mode:
authorMickie Betz <mbetz08@cmc.edu>2015-04-14 16:53:30 -0400
committerMickie Betz <mbetz08@cmc.edu>2015-04-14 16:53:30 -0400
commitd4f1990c537d761989de342a3dd682e5df46c51c (patch)
tree8445942a9f88bfd1a80ea728ee4732ce380a1dfb /tests/test_parser.py
parente036d40450fd3a30a71a81f63054597bbfd0f168 (diff)
downloadpython-coveragepy-d4f1990c537d761989de342a3dd682e5df46c51c.tar.gz
Including generator yield statements when doing end of code calculations issue 324
Diffstat (limited to 'tests/test_parser.py')
-rw-r--r--tests/test_parser.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/tests/test_parser.py b/tests/test_parser.py
index 244d4c7..a39820e 100644
--- a/tests/test_parser.py
+++ b/tests/test_parser.py
@@ -34,6 +34,19 @@ class PythonParserTest(CoverageTest):
2:1, 3:1, 4:2, 5:1, 7:1, 9:1, 10:1
})
+ def test_generator_exit_counts(self):
+ parser = self.parse_source("""\
+ # generators yield lines should only have one exit count
+ def gen(input):
+ for n in inp:
+ yield (i * 2 for i in range(n))
+
+ list(gen([1,2,3]))
+ """)
+ self.assertEqual(parser.exit_counts(), {
+ 2:1, 3:2, 4:1, 6:1
+ })
+
def test_try_except(self):
parser = self.parse_source("""\
try: