summaryrefslogtreecommitdiff
path: root/tests/basics/string_fstring_debug.py
diff options
context:
space:
mode:
authorDamien George <damien@micropython.org>2021-08-26 23:27:46 +1000
committerDamien George <damien@micropython.org>2021-08-26 23:56:02 +1000
commit8c4ba575fdd7730e71b339643f51ffadefbedb76 (patch)
tree1ada6627b806224e0c0105eff167e7c71b1d5d37 /tests/basics/string_fstring_debug.py
parent145fedef8d74a504c4b7c000e6c305602d07feff (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>
Diffstat (limited to 'tests/basics/string_fstring_debug.py')
-rw-r--r--tests/basics/string_fstring_debug.py23
1 files changed, 23 insertions, 0 deletions
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')