summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDamien George <damien@micropython.org>2025-08-11 14:07:09 +1000
committerDamien George <damien@micropython.org>2025-08-15 00:36:27 +1000
commit3c72c3a1e60cecc6ab05d5a81a1b50f42999f10f (patch)
tree61679c8c6f5cb6bed26bfa51cece551ea9219d13
parent95d1794afdbef4d0b57af321c0a5d69320dbe9fd (diff)
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>
-rw-r--r--tests/micropython/opt_level_lineno.py13
-rw-r--r--tests/micropython/opt_level_lineno.py.exp2
-rwxr-xr-xtests/run-tests.py1
3 files changed, 13 insertions, 3 deletions
diff --git a/tests/micropython/opt_level_lineno.py b/tests/micropython/opt_level_lineno.py
index d8253e54b..dda9092d8 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 469b90ba7..b50f0628c 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 "<string>", line 1, in <module>
+ File "<string>", line 1, in f
NameError: name 'xyz' isn't defined
diff --git a/tests/run-tests.py b/tests/run-tests.py
index d0a9121b4..f8174b2d3 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",