diff --git a/tests/micropython/incomplete_exc.py b/tests/micropython/incomplete_exc.py new file mode 100644 index 0000000000..2aec9a47b3 --- /dev/null +++ b/tests/micropython/incomplete_exc.py @@ -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") diff --git a/tests/micropython/incomplete_exc.py.exp b/tests/micropython/incomplete_exc.py.exp new file mode 100644 index 0000000000..f2e9c12f7f --- /dev/null +++ b/tests/micropython/incomplete_exc.py.exp @@ -0,0 +1,5 @@ +TypeError +TypeError +TypeError +TypeError +TypeError