summaryrefslogtreecommitdiff
path: root/tests/test_arcs.py
diff options
context:
space:
mode:
authorloic@dachary.org <loic@dachary.org>2016-12-18 01:56:31 +0100
committerloic@dachary.org <loic@dachary.org>2016-12-18 01:56:31 +0100
commitb8eaf57399f82872cb7b371bc5b8ff2e9679a9ba (patch)
treebcbf4f13e43abf67a8164f87daaf54f8bf37130c /tests/test_arcs.py
parent878363970556406d1eed322f6bd8747af1145462 (diff)
downloadpython-coveragepy-git-b8eaf57399f82872cb7b371bc5b8ff2e9679a9ba.tar.gz
finally happens before return in a try #493
In a try block such as: if expr: try: return finally print pass the print happens before the return and cannot be followed by pass. The general case is that when the body/else/handlers in a try block all have return, break etc., the code behind finally: has no arc to the statement following the try block. close #493 --HG-- branch : issue-493-2
Diffstat (limited to 'tests/test_arcs.py')
-rw-r--r--tests/test_arcs.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/test_arcs.py b/tests/test_arcs.py
index b03ac533..a245e214 100644
--- a/tests/test_arcs.py
+++ b/tests/test_arcs.py
@@ -774,6 +774,24 @@ class ExceptionArcTest(CoverageTest):
arcz=".1 12 28 89 9. -23 34 46 6-2",
)
+ def test_return_finally_before_return(self):
+ self.check_coverage("""\
+ a = []
+ def check_token(data):
+ if data:
+ try:
+ return 1
+ finally:
+ a.append(1)
+ return 2
+ assert 2 == check_token(False)
+ assert [] == a
+ assert 1 == check_token(True)
+ assert [1] == a
+ """,
+ arcz=".1 12 29 9A AB BC C-1 -23 34 45 57 7-2 38 8-2",
+ )
+
def test_except_jump_finally(self):
self.check_coverage("""\
def func(x):