mirror of
https://github.com/W3SLAV/micropython.git
synced 2025-06-19 03:55:44 -04:00
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>
This commit is contained in:
parent
dd4767a7d1
commit
30a9ccf4ca
@ -2,7 +2,6 @@
|
||||
print(b'123')
|
||||
print(br'123')
|
||||
print(rb'123')
|
||||
print(b'\u1234')
|
||||
|
||||
# construction
|
||||
print(bytes())
|
||||
|
3
tests/basics/bytes_escape_unicode.py
Normal file
3
tests/basics/bytes_escape_unicode.py
Normal file
@ -0,0 +1,3 @@
|
||||
# Coverage test for unicode escape in a bytes literal.
|
||||
# CPython issues a SyntaxWarning for this.
|
||||
print(b"\u1234")
|
1
tests/basics/bytes_escape_unicode.py.exp
Normal file
1
tests/basics/bytes_escape_unicode.py.exp
Normal file
@ -0,0 +1 @@
|
||||
b'\\u1234'
|
@ -5,7 +5,6 @@ print('abc')
|
||||
print(r'abc')
|
||||
print(u'abc')
|
||||
print(repr('\a\b\t\n\v\f\r'))
|
||||
print('\z') # unrecognised escape char
|
||||
|
||||
# construction
|
||||
print(str())
|
||||
|
4
tests/basics/string_escape_invalid.py
Normal file
4
tests/basics/string_escape_invalid.py
Normal file
@ -0,0 +1,4 @@
|
||||
# Test invalid escape characters.
|
||||
# CPython issues a SyntaxWarning for this.
|
||||
|
||||
print("\z")
|
1
tests/basics/string_escape_invalid.py.exp
Normal file
1
tests/basics/string_escape_invalid.py.exp
Normal file
@ -0,0 +1 @@
|
||||
\z
|
@ -29,21 +29,6 @@ print(f"a{[0,15,2][0:2][-1]:04x}")
|
||||
# Nested '{' and '}' characters.
|
||||
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
|
||||
# behave like str.format.
|
||||
print(f'{{}}')
|
||||
|
13
tests/basics/string_fstring_invalid.py
Normal file
13
tests/basics/string_fstring_invalid.py
Normal file
@ -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")
|
4
tests/basics/string_fstring_invalid.py.exp
Normal file
4
tests/basics/string_fstring_invalid.py.exp
Normal file
@ -0,0 +1,4 @@
|
||||
\
|
||||
#
|
||||
SyntaxError
|
||||
SyntaxError
|
Loading…
Reference in New Issue
Block a user