summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--coverage/parser.py8
-rw-r--r--tests/test_arcs.py15
2 files changed, 19 insertions, 4 deletions
diff --git a/coverage/parser.py b/coverage/parser.py
index 44cb1559..d85f0b57 100644
--- a/coverage/parser.py
+++ b/coverage/parser.py
@@ -426,8 +426,6 @@ class AstArcAnalyzer(object):
# TODO: listcomps hidden in lists: x = [[i for i in range(10)]]
# TODO: multi-line listcomps
# TODO: nested function definitions
- # TODO: multiple `except` clauses
- # TODO: return->finally
def process_break_exits(self, exits):
for block in self.blocks():
@@ -467,8 +465,10 @@ class AstArcAnalyzer(object):
def process_return_exits(self, exits):
for block in self.blocks():
- # TODO: need a check here for TryBlock
- if isinstance(block, FunctionBlock):
+ if isinstance(block, TryBlock) and block.final_start:
+ block.return_from.update(exits)
+ break
+ elif isinstance(block, FunctionBlock):
# TODO: what if there is no enclosing function?
for exit in exits:
self.arcs.add((exit, -block.start))
diff --git a/tests/test_arcs.py b/tests/test_arcs.py
index cd3aafff..88442049 100644
--- a/tests/test_arcs.py
+++ b/tests/test_arcs.py
@@ -682,6 +682,21 @@ class ExceptionArcTest(CoverageTest):
arcz_unpredicted="45 AB",
)
+ def test_return_finally(self):
+ self.check_coverage("""\
+ a = [1]
+ def func():
+ try:
+ return 10
+ finally:
+ a.append(6)
+
+ assert func() == 10
+ assert a == [1, 6]
+ """,
+ arcz=".1 12 28 89 9. .3 34 46 6-2",
+ )
+
class YieldTest(CoverageTest):
"""Arc tests for generators."""