summaryrefslogtreecommitdiff
path: root/test/farm
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2011-07-04 13:53:18 -0400
committerNed Batchelder <ned@nedbatchelder.com>2011-07-04 13:53:18 -0400
commit91692c31f757fe78e9a7376033f66772fc97f36b (patch)
tree53484cc5af1c35ab2588ecf104984ac0c109ad48 /test/farm
parent9a57b96e1688fba3038b86a2f2c8244167db158f (diff)
downloadpython-coveragepy-git-91692c31f757fe78e9a7376033f66772fc97f36b.tar.gz
for-else constructs are handled properly, avoiding bogus partial branch warnings. Fixes issue #122. Bonus irony: this also makes while 1 loops automatically understood better too.
Diffstat (limited to 'test/farm')
-rw-r--r--test/farm/html/run_b_branch.py6
-rw-r--r--test/farm/html/src/b.py19
2 files changed, 13 insertions, 12 deletions
diff --git a/test/farm/html/run_b_branch.py b/test/farm/html/run_b_branch.py
index f129e436..31543398 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 dffdd50f..3bf73a9f 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()