diff --git a/tests/micropython/opt_level_lineno.py b/tests/micropython/opt_level_lineno.py index d8253e54b4..dda9092d86 100644 --- a/tests/micropython/opt_level_lineno.py +++ b/tests/micropython/opt_level_lineno.py @@ -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() +""") diff --git a/tests/micropython/opt_level_lineno.py.exp b/tests/micropython/opt_level_lineno.py.exp index 469b90ba79..b50f0628c8 100644 --- a/tests/micropython/opt_level_lineno.py.exp +++ b/tests/micropython/opt_level_lineno.py.exp @@ -1,3 +1,3 @@ Traceback (most recent call last): - File "", line 1, in + File "", line 1, in f NameError: name 'xyz' isn't defined diff --git a/tests/run-tests.py b/tests/run-tests.py index d0a9121b4a..f8174b2d3b 100755 --- a/tests/run-tests.py +++ b/tests/run-tests.py @@ -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",