mirror of
https://github.com/micropython/micropython.git
synced 2026-03-10 19:00:30 +01:00
tests/micropython: Add a test for throwing incomplete exception.
This is a reproducer for #17117. Signed-off-by: Jeff Epler <jepler@unpythonic.net>
This commit is contained in:
committed by
Damien George
parent
6dbabc9267
commit
20500558f8
40
tests/micropython/incomplete_exc.py
Normal file
40
tests/micropython/incomplete_exc.py
Normal file
@@ -0,0 +1,40 @@
|
||||
# Test raising an incomplete exception.
|
||||
|
||||
|
||||
class C(Exception):
|
||||
def __init__(self):
|
||||
raise self
|
||||
|
||||
|
||||
class C1(C):
|
||||
pass
|
||||
|
||||
|
||||
class B:
|
||||
pass
|
||||
|
||||
|
||||
class C2(B, Exception):
|
||||
def __init__(self):
|
||||
raise self
|
||||
|
||||
|
||||
class C3(Exception, B):
|
||||
def __init__(self):
|
||||
raise self
|
||||
|
||||
|
||||
class D(Exception):
|
||||
pass
|
||||
|
||||
|
||||
class C4(D):
|
||||
def __init__(self):
|
||||
raise self
|
||||
|
||||
|
||||
for cls in C, C1, C2, C3, C4:
|
||||
try:
|
||||
cls()
|
||||
except TypeError as e:
|
||||
print("TypeError")
|
||||
5
tests/micropython/incomplete_exc.py.exp
Normal file
5
tests/micropython/incomplete_exc.py.exp
Normal file
@@ -0,0 +1,5 @@
|
||||
TypeError
|
||||
TypeError
|
||||
TypeError
|
||||
TypeError
|
||||
TypeError
|
||||
Reference in New Issue
Block a user