summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2011-08-02 22:37:21 -0400
committerNed Batchelder <ned@nedbatchelder.com>2011-08-02 22:37:21 -0400
commit7e1354114759ebc62c4f65edfb09921236bdcf37 (patch)
treeda55d51669fdeaf4d61ae90c7d5f274cfaa9c7e1
parent50e5019985f973291aeae64a9b8392ba37a9ff8b (diff)
parent0f1b0d30e306ad35b1e29912e0613e9bf2618c47 (diff)
downloadpython-coveragepy-7e1354114759ebc62c4f65edfb09921236bdcf37.tar.gz
Automated merge with ssh://bitbucket.org/ned/coveragepy
-rw-r--r--CHANGES.txt4
-rw-r--r--test/farm/html/run_b_branch.py6
-rw-r--r--test/farm/html/src/b.py19
-rw-r--r--test/test_arcs.py4
4 files changed, 19 insertions, 14 deletions
diff --git a/CHANGES.txt b/CHANGES.txt
index e41bfc1..0abfb25 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -8,6 +8,10 @@ Version 3.5.1
- The number of partial branches reported on the HTML summary page was
different than the number reported on the individual file pages. This is
now fixed.
+- for-else constructs are understood better, and don't cause erroneous partial
+ branch warnings. Fixes `issue 122`_.
+
+.. _issue 122: http://bitbucket.org/ned/coveragepy/issue/122/for-else-always-reports-missing-branch
Version 3.5 --- 29 June 2011
diff --git a/test/farm/html/run_b_branch.py b/test/farm/html/run_b_branch.py
index f129e43..3154339 100644
--- a/test/farm/html/run_b_branch.py
+++ b/test/farm/html/run_b_branch.py
@@ -15,14 +15,14 @@ compare("gold_b_branch", "html_b_branch", size_within=10, file_pattern="*.html")
contains("html_b_branch/b.html",
"<span class='key'>if</span> <span class='nam'>x</span> <span class='op'>&lt;</span> <span class='num'>2</span>",
"&nbsp; &nbsp; <span class='nam'>a</span> <span class='op'>=</span> <span class='num'>3</span>",
- "<span class='pc_cov'>76%</span>",
+ "<span class='pc_cov'>70%</span>",
"<span class='annotate' title='no jump to this line number'>8</span>",
"<span class='annotate' title='no jump to this line number'>exit</span>",
- "<span class='annotate' title='no jumps to these line numbers'>25&nbsp;&nbsp; 26</span>",
+ "<span class='annotate' title='no jumps to these line numbers'>23&nbsp;&nbsp; 25</span>",
)
contains("html_b_branch/index.html",
"<a href='b.html'>b</a>",
- "<span class='pc_cov'>76%</span>"
+ "<span class='pc_cov'>70%</span>"
)
clean("html_b_branch")
diff --git a/test/farm/html/src/b.py b/test/farm/html/src/b.py
index dffdd50..3bf73a9 100644
--- a/test/farm/html/src/b.py
+++ b/test/farm/html/src/b.py
@@ -16,13 +16,14 @@ def two(x):
two(1)
-def three_way():
- # for-else can be a three-way branch.
- for i in range(10):
- if i == 3:
- break
- else:
- return 23
- return 17
+def three():
+ try:
+ # This if has two branches, *neither* one taken.
+ if name_error_this_variable_doesnt_exist:
+ a = 1
+ else:
+ a = 2
+ except:
+ pass
-three_way()
+three()
diff --git a/test/test_arcs.py b/test/test_arcs.py
index 9f86ecd..2c98317 100644
--- a/test/test_arcs.py
+++ b/test/test_arcs.py
@@ -213,12 +213,12 @@ class LoopArcTest(CoverageTest):
i += 1
assert a == 4 and i == 3
""",
- arcz=".1 12 23 27 34 45 36 63 57 7.",
+ arcz=".1 12 23 34 45 36 63 57 7.",
)
# With "while True", 2.x thinks it's computation, 3.x thinks it's
# constant.
if sys.version_info >= (3, 0):
- arcz = ".1 12 23 27 34 45 36 63 57 7."
+ arcz = ".1 12 23 34 45 36 63 57 7."
else:
arcz = ".1 12 23 27 34 45 36 62 57 7."
self.check_coverage("""\