summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2015-12-28 16:48:05 -0500
committerNed Batchelder <ned@nedbatchelder.com>2015-12-28 16:48:05 -0500
commit35c09545a39e70065ce55264f2688ac87dd6a725 (patch)
tree3e1bedf68f383810c65cdbce4f4d0c39e1245a66 /tests
parentb7a35186425cfef265548afc75b527752bed0c9a (diff)
downloadpython-coveragepy-git-35c09545a39e70065ce55264f2688ac87dd6a725.tar.gz
Execution flows from the end of exception handlers to the finally
--HG-- branch : ast-branch
Diffstat (limited to 'tests')
-rw-r--r--tests/test_arcs.py46
1 files changed, 44 insertions, 2 deletions
diff --git a/tests/test_arcs.py b/tests/test_arcs.py
index 04c0df6e..2d90b067 100644
--- a/tests/test_arcs.py
+++ b/tests/test_arcs.py
@@ -581,8 +581,50 @@ class ExceptionArcTest(CoverageTest):
assert a == 3 and b == 1 and c == 9
""",
arcz=".1 12 23 45 39 59 67 79 9A A.", arcz_missing="45 59 67 79")
- # TODO: do it again, with line 3 raising a caught exception
- # TODO: do it again, with line 3 raising an uncaught exception.
+ self.check_coverage("""\
+ a, b, c = 1, 1, 1
+ try:
+ a = int("xyz") # ValueError
+ except ValueError:
+ b = 5
+ except IndexError:
+ a = 7
+ finally:
+ c = 9
+ assert a == 1 and b == 5 and c == 9
+ """,
+ arcz=".1 12 23 45 39 59 67 79 9A A.", arcz_missing="39 67 79",
+ arcz_unpredicted="34")
+ self.check_coverage("""\
+ a, b, c = 1, 1, 1
+ try:
+ a = [1][3] # IndexError
+ except ValueError:
+ b = 5
+ except IndexError:
+ a = 7
+ finally:
+ c = 9
+ assert a == 7 and b == 1 and c == 9
+ """,
+ arcz=".1 12 23 45 39 59 67 79 9A A.", arcz_missing="39 45 59",
+ arcz_unpredicted="34 46")
+ self.check_coverage("""\
+ a, b, c = 1, 1, 1
+ try:
+ try:
+ a = 4/0 # ZeroDivisionError
+ except ValueError:
+ b = 6
+ except IndexError:
+ a = 8
+ finally:
+ c = 10
+ except ZeroDivisionError:
+ pass
+ assert a == 1 and b == 1 and c == 10
+ """,
+ arcz=".1 12 23 34 4A 56 6A 78 8A AB AD BC CD D.", arcz_missing="45 56 57 78")
class YieldTest(CoverageTest):