summaryrefslogtreecommitdiff
path: root/coverage/results.py
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2015-04-20 12:15:37 -0400
committerNed Batchelder <ned@nedbatchelder.com>2015-04-20 12:15:37 -0400
commitde4cfde7b1f7b3d3bee11a26b4c1bb3ae598259c (patch)
treeff4911093102a0888abc6563f6fca31ebfc62a2e /coverage/results.py
parentdd20fcfbcce90933099b10629424dc0cccafc5db (diff)
downloadpython-coveragepy-git-de4cfde7b1f7b3d3bee11a26b4c1bb3ae598259c.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 'coverage/results.py')
-rw-r--r--coverage/results.py3
1 files changed, 3 insertions, 0 deletions
diff --git a/coverage/results.py b/coverage/results.py
index 0b27971f..def3a075 100644
--- a/coverage/results.py
+++ b/coverage/results.py
@@ -101,10 +101,13 @@ class Analysis(object):
# Exclude arcs here which connect a line to itself. They can occur
# in executed data in some cases. This is where they can cause
# trouble, and here is where it's the least burden to remove them.
+ # Also, generators can somehow cause arcs from "enter" to "exit", so
+ # make sure we have at least one positive value.
unpredicted = (
e for e in executed
if e not in possible
and e[0] != e[1]
+ and (e[0] > 0 or e[1] > 0)
)
return sorted(unpredicted)