diff options
author | loic <loic@dachary.org> | 2016-12-18 01:56:31 +0100 |
---|---|---|
committer | loic <loic@dachary.org> | 2016-12-18 01:56:31 +0100 |
commit | ff3b97a0b4f7ca264f7b7897cc101521485cdff8 (patch) | |
tree | fc74e399e39134aa8af83c61c8ea663fcf04e95a /tests/test_arcs.py | |
parent | b33628b4918f47694e89526955cf83b9764f6562 (diff) | |
download | python-coveragepy-issue-493-2.tar.gz |
finally happens before return in a try #493issue-493-2
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
Diffstat (limited to 'tests/test_arcs.py')
-rw-r--r-- | tests/test_arcs.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/test_arcs.py b/tests/test_arcs.py index b03ac53..a245e21 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): |