8000 Add tests for chained exceptions (failing) · jepler/circuitpython@41eee0d · GitHub
[go: up one dir, main page]

Skip to content

Commit 41eee0d

Browse files
committed
Add tests for chained exceptions (failing)
1 parent 0de50aa commit 41eee0d

File tree

1 file changed

+58
-0
lines changed

1 file changed

+58
-0
lines changed

tests/circuitpython/traceback_test_chained.py

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,3 +72,61 @@ def print_exc_info(e, chain=True):
7272
print_exc_info(e, chain=False)
7373
print_exc_info(e)
7474
print()
75+
76+
class SomeException(RuntimeError):
77+
pass
78+
79+
try:
80+
try:
81+
raise Exception("inner")
82+
except Exception as inner:
83+
raise SomeException("outer") from inner
84+
except Exception as e:
85+
print_exc_info(e)
86+
87+
try:
88+
try:
89+
raise Exception("inner")
90+
except Exception as inner:
91+
l = inner
92+
raise SomeException("outer") from l
93+
except Exception as e:
94+
print_exc_info(e)
95+
print()
96+
97+
try:
98+
try:
99+
raise SomeException("inner")
100+
except Exception as inner:
101+
raise Exception("outer") from inner
102+
except Exception as e:
103+
print_exc_info(e)
104+
105+
try:
106+
try:
107+
raise SomeException("inner")
108+
except Exception as inner:
109+
l = inner
110+
raise Exception("outer") from l
111+
except Exception as e:
112+
print(e, e.__cause__, e.__context__)
113+
pri 9EA0 nt_exc_info(e)
114+
print()
115+
116+
try:
117+
try:
118+
raise SomeException("inner")
119+
except Exception as inner:
120+
raise SomeException("outer") from inner
121+
except Exception as e:
122+
print_exc_info(e)
123+
124+
try:
125+
try:
126+
raise SomeException("inner")
127+
except Exception as inner:
128+
l = inner
129+
raise SomeException("outer") from l
130+
except Exception as e:
131+
print_exc_info(e)
132+
print()

0 commit comments

Comments
 (0)
0