Files
micropython/tests/basics/string_tstring_whitespace.py
Koudai Aono bdef10a92b tests: Add full feature and coverage tests for PEP 750 template strings.
Includes corresponding .exp files because this feature is only available in
Python 3.14+.

Tests for `!a` conversion specifier and space after `!` are not included
because they are not supported by MicroPython.

Signed-off-by: Koudai Aono <koxudaxi@gmail.com>
Signed-off-by: Damien George <damien@micropython.org>
2026-03-09 23:47:33 +11:00

26 lines
744 B
Python

print("# Empty expression (whitespace only)")
try:
exec('t"{ }"')
print("ERROR: Should have raised SyntaxError")
except SyntaxError as e:
print("Empty expr (space): SyntaxError (correct)")
try:
exec('t"{\t}"')
print("ERROR: Should have raised SyntaxError")
except SyntaxError as e:
print("Empty expr (tab): SyntaxError (correct)")
try:
exec('t"{\n}"')
print("ERROR: Should have raised SyntaxError")
except SyntaxError as e:
print("Empty expr (newline): SyntaxError (correct)")
print("\n# Lexer escape sequence: invalid then valid")
try:
exec("t'\\U00200000\\x41'")
print("ERROR: Should have raised SyntaxError")
except SyntaxError as e:
print("Invalid escape sequence: SyntaxError (correct)")