diff options
author | Ned Batchelder <ned@nedbatchelder.com> | 2016-02-15 10:11:25 -0500 |
---|---|---|
committer | Ned Batchelder <ned@nedbatchelder.com> | 2016-02-15 10:11:25 -0500 |
commit | babe79f03ea50e26accc397480e1dee2ea53152e (patch) | |
tree | aedae2306608c44f547b64c81d4ee55f2b4c4d7b /coverage/parser.py | |
parent | d2f0e8e892417a453a9c1bd9b6237366520d7d51 (diff) | |
download | python-coveragepy-git-babe79f03ea50e26accc397480e1dee2ea53152e.tar.gz |
Add missing branch explanations for while-loop
Diffstat (limited to 'coverage/parser.py')
-rw-r--r-- | coverage/parser.py | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/coverage/parser.py b/coverage/parser.py index 84cd3d1d..f84133d2 100644 --- a/coverage/parser.py +++ b/coverage/parser.py @@ -870,19 +870,21 @@ class AstArcAnalyzer(object): if constant_test: to_top = self.line_for_node(node.body[0]) self.block_stack.append(LoopBlock(start=start)) - exits = self.add_body_arcs(node.body, from_start=ArcStart(start)) + from_start = ArcStart(start, cause="the condition on line {lineno} was never true") + exits = self.add_body_arcs(node.body, from_start=from_start) for xit in exits: - self.add_arc(xit.lineno, to_top) + self.add_arc(xit.lineno, to_top, xit.cause) exits = set() my_block = self.block_stack.pop() exits.update(my_block.break_exits) + from_start = ArcStart(start, cause="the condition on line {lineno} was never false") if node.orelse: - else_exits = self.add_body_arcs(node.orelse, from_start=ArcStart(start)) + else_exits = self.add_body_arcs(node.orelse, from_start=from_start) exits |= else_exits else: # No `else` clause: you can exit from the start. if not constant_test: - exits.add(ArcStart(start)) + exits.add(from_start) return exits @contract(returns='ArcStarts') |