diff options
author | Ned Batchelder <ned@nedbatchelder.com> | 2015-04-20 12:15:37 -0400 |
---|---|---|
committer | Ned Batchelder <ned@nedbatchelder.com> | 2015-04-20 12:15:37 -0400 |
commit | 30a6a037158eebf062c7da735e0cb905a489d21c (patch) | |
tree | 851e6073d790fa7d1b6d1fd69e9d89345b0b1e81 /tests/test_parser.py | |
parent | 6246b2bb47198e68341cfc8967274edbb751c43e (diff) | |
download | python-coveragepy-30a6a037158eebf062c7da735e0cb905a489d21c.tar.gz |
Fix branch coverage for yield statements. #308 #324
Turns out the "call" and "return" trace events are really "start frame" and
"end frame". They happen not only when functions are entered and left, but
when generators yield and resume. We aren't interested in arcs into and out
of yield statements, so the trace functions look more closely to see what's
really happening, and record an arc in human-friendly terms.
Thanks for Mickie Betz for pushing on this bug, although her code is no
longer here. :(
Diffstat (limited to 'tests/test_parser.py')
-rw-r--r-- | tests/test_parser.py | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/tests/test_parser.py b/tests/test_parser.py index 04c345e..81916a9 100644 --- a/tests/test_parser.py +++ b/tests/test_parser.py @@ -35,7 +35,6 @@ class PythonParserTest(CoverageTest): }) def test_generator_exit_counts(self): - # Generators' yield lines should only have one exit count. # https://bitbucket.org/ned/coveragepy/issue/324/yield-in-loop-confuses-branch-coverage parser = self.parse_source("""\ def gen(input): @@ -45,7 +44,10 @@ class PythonParserTest(CoverageTest): list(gen([1,2,3])) """) self.assertEqual(parser.exit_counts(), { - 1:1, 2:2, 3:1, 5:1 + 1:1, # def -> list + 2:2, # for -> yield; for -> exit + 3:2, # yield -> for; genexp exit + 5:1, # list -> exit }) def test_try_except(self): |