summaryrefslogtreecommitdiffstatshomepage
path: root/tests/basics/string_fstring_invalid.py
diff options
context:
space:
mode:
authorDamien George <damien@micropython.org>2024-05-28 10:52:12 +1000
committerDamien George <damien@micropython.org>2024-05-28 10:58:37 +1000
commit30a9ccf4caa72c62cb8656a1572518fef34b08a4 (patch)
tree125f373f880e1b3e1b632d1d5e2f5e90665e8cc3 /tests/basics/string_fstring_invalid.py
parentdd4767a7d1ba57f107a652310fdfbd0f0274a0c8 (diff)
downloadmicropython-30a9ccf4caa72c62cb8656a1572518fef34b08a4.tar.gz
micropython-30a9ccf4caa72c62cb8656a1572518fef34b08a4.zip
tests/basics: Move str/bytes tests that give SyntaxWarning to sep file.
In CPython 3.12 these invalid str/bytes/fstring escapes will issue a SyntaxWarning, and so differ to MicroPython. Signed-off-by: Damien George <damien@micropython.org>
Diffstat (limited to 'tests/basics/string_fstring_invalid.py')
-rw-r--r--tests/basics/string_fstring_invalid.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/tests/basics/string_fstring_invalid.py b/tests/basics/string_fstring_invalid.py
new file mode 100644
index 0000000000..6fce323c5b
--- /dev/null
+++ b/tests/basics/string_fstring_invalid.py
@@ -0,0 +1,13 @@
+# PEP-0498 specifies that '\\' and '#' must be disallowed explicitly, whereas
+# MicroPython relies on the syntax error as a result of the substitution.
+
+print(f"\\")
+print(f"#")
+try:
+ eval("f'{\}'")
+except SyntaxError:
+ print("SyntaxError")
+try:
+ eval("f'{#}'")
+except SyntaxError:
+ print("SyntaxError")