diff options
| author | Damien George <damien@micropython.org> | 2021-08-26 23:27:46 +1000 |
|---|---|---|
| committer | Damien George <damien@micropython.org> | 2021-08-26 23:56:02 +1000 |
| commit | 8c4ba575fdd7730e71b339643f51ffadefbedb76 (patch) | |
| tree | 1ada6627b806224e0c0105eff167e7c71b1d5d37 | |
| parent | 145fedef8d74a504c4b7c000e6c305602d07feff (diff) | |
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>
| -rw-r--r-- | tests/basics/string_fstring.py | 6 | ||||
| -rw-r--r-- | tests/basics/string_fstring_debug.py | 23 | ||||
| -rw-r--r-- | tests/basics/string_fstring_debug.py.exp | 6 | ||||
| -rwxr-xr-x | tools/tinytest-codegen.py | 1 |
4 files changed, 30 insertions, 6 deletions
diff --git a/tests/basics/string_fstring.py b/tests/basics/string_fstring.py index efb7e5a8e..4f7225fca 100644 --- a/tests/basics/string_fstring.py +++ b/tests/basics/string_fstring.py @@ -12,17 +12,11 @@ print(f"""no interpolation""") x, y = 1, 2 print(f'{x}') print(f'{x:08x}') -print(f'{x=}') -print(f'{x=:08x}') print(f'a {x} b {y} c') print(f'a {x:08x} b {y} c') -print(f'a {x=} b {y} c') -print(f'a {x=:08x} b {y} c') print(f'a {"hello"} b') print(f'a {f() + g("foo") + h()} b') -print(f'a {f() + g("foo") + h()=} b') -print(f'a {f() + g("foo") + h()=:08x} b') def foo(a, b): return f'{x}{y}{a}{b}' diff --git a/tests/basics/string_fstring_debug.py b/tests/basics/string_fstring_debug.py new file mode 100644 index 000000000..76a448ca0 --- /dev/null +++ b/tests/basics/string_fstring_debug.py @@ -0,0 +1,23 @@ +# test f-string debug feature {x=} + + +def f(): + return 4 + + +def g(_): + return 5 + + +def h(): + return 6 + + +x, y = 1, 2 +print(f"{x=}") +print(f"{x=:08x}") +print(f"a {x=} b {y} c") +print(f"a {x=:08x} b {y} c") + +print(f'a {f() + g("foo") + h()=} b') +print(f'a {f() + g("foo") + h()=:08x} b') diff --git a/tests/basics/string_fstring_debug.py.exp b/tests/basics/string_fstring_debug.py.exp new file mode 100644 index 000000000..563030f40 --- /dev/null +++ b/tests/basics/string_fstring_debug.py.exp @@ -0,0 +1,6 @@ +x=1 +x=00000001 +a x=1 b 2 c +a x=00000001 b 2 c +a f() + g("foo") + h()=15 b +a f() + g("foo") + h()=0000000f b diff --git a/tools/tinytest-codegen.py b/tools/tinytest-codegen.py index ddbe62b84..f1169a34d 100755 --- a/tools/tinytest-codegen.py +++ b/tools/tinytest-codegen.py @@ -101,6 +101,7 @@ exclude_tests = ( "misc/sys_settrace_features.py", # don't have f-string "basics/string_fstring.py", + "basics/string_fstring_debug.py", ) output = [] |
