forked from Rust-related/RustPython
Add test for exception with_traceback
This commit is contained in:
@@ -3,5 +3,15 @@ import traceback
|
||||
try:
|
||||
1/0
|
||||
except ZeroDivisionError as ex:
|
||||
tb = traceback.format_list(traceback.extract_tb(ex.__traceback__))
|
||||
tb = traceback.extract_tb(ex.__traceback__)
|
||||
assert len(tb) == 1
|
||||
|
||||
|
||||
try:
|
||||
try:
|
||||
1/0
|
||||
except ZeroDivisionError as ex:
|
||||
raise KeyError().with_traceback(ex.__traceback__)
|
||||
except KeyError as ex2:
|
||||
tb = traceback.extract_tb(ex2.__traceback__)
|
||||
assert tb[1].line == "1/0"
|
||||
|
||||
Reference in New Issue
Block a user