tests/basics: Add test for use of return within try-except.
The case of a return statement in the try suite of a try-except statement was previously only tested by builtin_compile.py, and only then in the part of this test which checked for the existence of the compile builtin. So this patch adds an explicit unit test for this case.
This commit is contained in:
parent
bc36521386
commit
430efb0444
11
tests/basics/try_return.py
Normal file
11
tests/basics/try_return.py
Normal file
@ -0,0 +1,11 @@
|
||||
# test use of return with try-except
|
||||
|
||||
def f(l, i):
|
||||
try:
|
||||
return l[i]
|
||||
except IndexError:
|
||||
print('IndexError')
|
||||
return -1
|
||||
|
||||
print(f([1], 0))
|
||||
print(f([], 0))
|
Loading…
Reference in New Issue
Block a user