micropython/tests/micropython/opt_level_lineno.py
Damien George 381cd730c8 tests/micropython: Improve skipping of tests using micropython module.
Signed-off-by: Damien George <damien@micropython.org>
2025-10-01 23:59:15 +10:00

24 lines
498 B
Python

# test micropython.opt_level() and line numbers
try:
import micropython
except ImportError:
print("SKIP")
raise SystemExit
# check that level 3 doesn't store line numbers
# the expected output is that any line is printed as "line 1"
micropython.opt_level(3)
# force bytecode emitter, because native emitter doesn't store line numbers
exec("""
@micropython.bytecode
def f():
try:
xyz
except NameError as er:
import sys
sys.print_exception(er)
f()
""")