mirror of
https://github.com/python/cpython.git
synced 2025-08-09 19:38:42 +00:00
[3.12] gh-115931: Fix SyntaxWarning
s in test_unparse
(GH-115935) (#115948)
gh-115931: Fix `SyntaxWarning`s in `test_unparse` (GH-115935)
(cherry picked from commit b7383b8b71
)
Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
This commit is contained in:
parent
79061af448
commit
8668b3cc2d
1 changed files with 11 additions and 2 deletions
|
@ -650,9 +650,18 @@ class CosmeticTestCase(ASTTestCase):
|
|||
self.check_ast_roundtrip("""f'''""\"''\\'{""\"\\n\\"'''""\" '''\\n'''}''' """)
|
||||
|
||||
def test_backslash_in_format_spec(self):
|
||||
self.check_ast_roundtrip("""f"{x:\\ }" """)
|
||||
import re
|
||||
msg = re.escape("invalid escape sequence '\\ '")
|
||||
with self.assertWarnsRegex(SyntaxWarning, msg):
|
||||
self.check_ast_roundtrip("""f"{x:\\ }" """)
|
||||
self.check_ast_roundtrip("""f"{x:\\n}" """)
|
||||
|
||||
self.check_ast_roundtrip("""f"{x:\\\\ }" """)
|
||||
self.check_ast_roundtrip("""f"{x:\\\\\\ }" """)
|
||||
|
||||
with self.assertWarnsRegex(SyntaxWarning, msg):
|
||||
self.check_ast_roundtrip("""f"{x:\\\\\\ }" """)
|
||||
self.check_ast_roundtrip("""f"{x:\\\\\\n}" """)
|
||||
|
||||
self.check_ast_roundtrip("""f"{x:\\\\\\\\ }" """)
|
||||
|
||||
def test_quote_in_format_spec(self):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue