summaryrefslogtreecommitdiff
path: root/coverage/parser.py
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2016-02-15 10:11:25 -0500
committerNed Batchelder <ned@nedbatchelder.com>2016-02-15 10:11:25 -0500
commitd77a0119140a42a848e21f3f13005bf63c7cad53 (patch)
treeac2d8c99d9a52523c67412095ed1c72ae2b336dd /coverage/parser.py
parent708daa3402ada27986414c8b78de4fdeba16da25 (diff)
downloadpython-coveragepy-d77a0119140a42a848e21f3f13005bf63c7cad53.tar.gz
Add missing branch explanations for while-loop
Diffstat (limited to 'coverage/parser.py')
-rw-r--r--coverage/parser.py10
1 files changed, 6 insertions, 4 deletions
diff --git a/coverage/parser.py b/coverage/parser.py
index 84cd3d1..f84133d 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')