Files
micropython/tests/stress/qstr_limit_str_modulo.py
Damien George da568a3a30 tests/stress: Improve qstr_limit test to run on minimal targets.
Changes here are:
- Split out string format module sub-test to a separate test file, so it
  can be skipped on targets that don't have str% capabilities.
- Print the whole type instead of `.__name__` to support targets that don't
  have `.__name__` enabled (this still tests the same thing).
- Print `RuntimeError` exception message to be sure the correct exception
  is being raised.

This test now runs on unix and zephyr minimal configurations.

Signed-off-by: Damien George <damien@micropython.org>
2025-10-01 23:58:57 +10:00

22 lines
517 B
Python

# Test interning qstrs that go over the qstr length limit (255 bytes in default configuration).
# The tests here are specifically for str formatting with %.
try:
"" % ()
except TypeError:
print("SKIP")
raise SystemExit
def make_id(n, base="a"):
return "".join(chr(ord(base) + i % 26) for i in range(n))
# modulo format with keys
for l in range(254, 259):
id = make_id(l)
try:
print(("%(" + id + ")d") % {id: l})
except RuntimeError as er:
print("RuntimeError", er, l)