Commit 30a9ccf4 authored by Damien George's avatar Damien George

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: default avatarDamien George <damien@micropython.org>
parent dd4767a7
...@@ -2,7 +2,6 @@ ...@@ -2,7 +2,6 @@
print(b'123') print(b'123')
print(br'123') print(br'123')
print(rb'123') print(rb'123')
print(b'\u1234')
# construction # construction
print(bytes()) print(bytes())
......
# Coverage test for unicode escape in a bytes literal.
# CPython issues a SyntaxWarning for this.
print(b"\u1234")
...@@ -5,7 +5,6 @@ print('abc') ...@@ -5,7 +5,6 @@ print('abc')
print(r'abc') print(r'abc')
print(u'abc') print(u'abc')
print(repr('\a\b\t\n\v\f\r')) print(repr('\a\b\t\n\v\f\r'))
print('\z') # unrecognised escape char
# construction # construction
print(str()) print(str())
......
# Test invalid escape characters.
# CPython issues a SyntaxWarning for this.
print("\z")
...@@ -29,21 +29,6 @@ print(f"a{[0,15,2][0:2][-1]:04x}") ...@@ -29,21 +29,6 @@ print(f"a{[0,15,2][0:2][-1]:04x}")
# Nested '{' and '}' characters. # Nested '{' and '}' characters.
print(f"a{ {0,1,2}}") print(f"a{ {0,1,2}}")
# 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')
# PEP-0498 specifies that handling of double braces '{{' or '}}' should # PEP-0498 specifies that handling of double braces '{{' or '}}' should
# behave like str.format. # behave like str.format.
print(f'{{}}') print(f'{{}}')
......
# 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")
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment