8000 gh-115931: Fix `SyntaxWarning`s in `test_unparse` (#115935) · python/cpython@b7383b8 · GitHub
[go: up one dir, main page]

Skip to content

Commit b7383b8

Browse files
authored
gh-115931: Fix SyntaxWarnings in test_unparse (#115935)
1 parent 37f5d06 commit b7383b8

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

Lib/test/test_unparse.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -650,9 +650,18 @@ def test_multiquote_joined_string(self):
650650
self.check_ast_roundtrip("""f'''""\"''\\'{""\"\\n\\"'''""\" '''\\n'''}''' """)
651651

652652
def test_backslash_in_format_spec(self):
653-
self.check_ast_roundtrip("""f"{x:\\ }" """)
653+
import re
654+
msg = re.escape("invalid escape sequence '\\ '")
655+
with self.assertWarnsRegex(SyntaxWarning, msg):
656+
self.check_ast_roundtrip("""f"{x:\\ }" """)
657+
self.check_ast_roundtrip("""f"{x:\\n}" """)
658+
654659
self.check_ast_roundtrip("""f"{x:\\\\ }" """)
655-
self.check_ast_roundtrip("""f"{x:\\\\\\ }" """)
660+
661+
with self.assertWarnsRegex(SyntaxWarning, msg):
662+
self.check_ast_roundtrip("""f"{x:\\\\\\ }" """)
663+
self.check_ast_roundtrip("""f"{x:\\\\\\n}" """)
664+
656665
self.check_ast_roundtrip("""f"{x:\\\\\\\\ }" """)
657666

658667
def test_quote_in_format_spec(self):

0 commit comments

Comments
 (0)
0