Skip to content

Commit 8c4ba57

Browse files
committed
tests/basics: Split f-string debug printing to separate file with .exp.
This feature {x=} was introduced in Python 3.8 so needs a separate .exp file to run on earlier Python versions. See https://bugs.python.org/issue36817 Signed-off-by: Damien George <damien@micropython.org>
1 parent 145fede commit 8c4ba57

File tree

4 files changed

+30
-6
lines changed

4 files changed

+30
-6
lines changed

tests/basics/string_fstring.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,11 @@ def h():
1212
x, y = 1, 2
1313
print(f'{x}')
1414
print(f'{x:08x}')
15-
print(f'{x=}')
16-
print(f'{x=:08x}')
1715
print(f'a {x} b {y} c')
1816
print(f'a {x:08x} b {y} c')
19-
print(f'a {x=} b {y} c')
20-
print(f'a {x=:08x} b {y} c')
2117

2218
print(f'a {"hello"} b')
2319
print(f'a {f() + g("foo") + h()} b')
24-
print(f'a {f() + g("foo") + h()=} b')
25-
print(f'a {f() + g("foo") + h()=:08x} b')
2620

2721
def foo(a, b):
2822
return f'{x}{y}{a}{b}'
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# test f-string debug feature {x=}
2+
3+
4+
def f():
5+
return 4
6+
7+
8+
def g(_):
9+
return 5
10+
11+
12+
def h():
13+
return 6
14+
15+
16+
x, y = 1, 2
17+
print(f"{x=}")
18+
print(f"{x=:08x}")
19+
print(f"a {x=} b {y} c")
20+
print(f"a {x=:08x} b {y} c")
21+
22+
print(f'a {f() + g("foo") + h()=} b')
23+
print(f'a {f() + g("foo") + h()=:08x} b')
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
x=1
2+
x=00000001
3+
a x=1 b 2 c
4+
a x=00000001 b 2 c
5+
a f() + g("foo") + h()=15 b
6+
a f() + g("foo") + h()=0000000f b

tools/tinytest-codegen.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ def script_to_map(test_file):
101101
"misc/sys_settrace_features.py",
102102
# don't have f-string
103103
"basics/string_fstring.py",
104+
"basics/string_fstring_debug.py",
104105
)
105106

106107
output = []

0 commit comments

Comments
 (0)