pocketpy/tests/80_traceback.py
blueloveTH 9d6f044d33 Squashed commit of the following:
commit b584de5c3d4603a476cdd60830289104784a4942
Author: blueloveTH <blueloveth@foxmail.com>
Date:   Thu Jun 13 10:46:07 2024 +0800

    some fix

commit 1fe8a3280949d724ddab9c6b1476e1b55c5beb9d
Author: blueloveTH <blueloveth@foxmail.com>
Date:   Wed Jun 12 22:08:09 2024 +0800

    backup
2024-06-13 10:46:22 +08:00

19 lines
366 B
Python

import traceback
try:
a = {'123': 4}
b = a[6]
except KeyError:
actual = traceback.format_exc()
expected = '''Traceback (most recent call last):
File "80_traceback.py", line 5
b = a[6]
KeyError: 6'''
if actual != expected:
print('--- ACTUAL RESULT -----')
print(actual)
print('--- EXPECTED RESULT ---')
print(expected)
exit(1)