summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--coverage/parser.py4
-rw-r--r--tests/test_arcs.py46
2 files changed, 46 insertions, 4 deletions
diff --git a/coverage/parser.py b/coverage/parser.py
index 4b920f10..65b1f0fb 100644
--- a/coverage/parser.py
+++ b/coverage/parser.py
@@ -432,9 +432,9 @@ class AstArcAnalyzer(object):
# TODO: handler_node.name and handler_node.type
handler_exits |= self.add_body_arcs(handler_node.body, from_line=handler_start)
# TODO: node.orelse
- # TODO: node.finalbody
+ exits |= handler_exits
if node.finalbody:
- exits = self.add_body_arcs(node.finalbody, prev_lines=exits|handler_exits)
+ exits = self.add_body_arcs(node.finalbody, prev_lines=exits)
return exits
def handle_While(self, node):
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):