Files
micropython/tests/basics/string_tstring_constructor.py.exp
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

41 lines
1.5 KiB
Plaintext

=== Constructor basic usage ===
Template repr: Template(strings=('hello ', 'world'), interpolations=(Interpolation(42, 'x', None, ''),))
Varargs constructor: strings=('Hello ', '!'), values=('World',)
Varargs merged strings: ('AB', 'CD')
Leading interpolation strings: ('', ' tail')
Trailing interpolation strings: ('head ', '')
Interpolation only strings: ('', '', '')
=== Special cases ===
Interp read-only: AttributeError
Whitespace trim: 'Template(strings=('', ''), interpolations=(Interpolation(None, ' ', None, ''),))'
Debug =: Template(strings=('', ''), interpolations=(Interpolation(42, 'x=', None, ''),))
Custom !r: Template(strings=('', ''), interpolations=(Interpolation(CustomRepr, 'obj', 'r', ''),))
Custom !s: Template(strings=('', ''), interpolations=(Interpolation(CustomRepr, 'obj', 's', ''),))
Empty start iter: ['Interpolation', 'str']
Iterator edge: ['Interpolation', 'Interpolation']
=== Values property ===
Values[0]: ()
Values[1]: (0,)
Values[2]: (0, 1)
Values[3]: (0, 1, 2)
Values[4]: (0, 1, 2, 3)
Values[5]: (0, 1, 2, 3, 4)
Values[6]: (0, 1, 2, 3, 4, 5)
=== Multiple consecutive strings ===
Multiple strings concatenated: OK
=== Template() constructor with many interpolations ===
Template() constructor: OK (20 interpolations)
=== vstr string concatenation ===
vstr concat: 'Template(strings=('part1part2part3part4', 'end'), interpolations=(Interpolation(1, 'x', None, ''),))'
=== High byte handling ===
High bytes: len=5, first=0x7f, last=0xff
Octal high bytes: OK, len=3
Constructor tests completed!