tests/micropython/opt_level_lineno.py: Force test func to use bytecode.

So that the test can run the same on all targets when used with the native
emitter.

Signed-off-by: Damien George <damien@micropython.org>
This commit is contained in:
Damien George 2025-08-11 14:07:09 +10:00
parent 95d1794afd
commit 3c72c3a1e6
3 changed files with 13 additions and 3 deletions

View file

@ -3,4 +3,15 @@ import micropython as micropython
# 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)
exec("try:\n xyz\nexcept NameError as er:\n import sys\n sys.print_exception(er)")
# 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()
""")

View file

@ -1,3 +1,3 @@
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "<string>", line 1, in f
NameError: name 'xyz' isn't defined

View file

@ -131,7 +131,6 @@ emitter_tests_to_skip = {
"misc/print_exception.py",
"micropython/emg_exc.py",
"micropython/heapalloc_traceback.py",
"micropython/opt_level_lineno.py",
"thread/thread_exc2.py",
# These require stack-allocated slice optimisation.
"micropython/heapalloc_slice.py",