https://github.com/python/cpython/commit/b7383b8b71d49c761480ae9a8b2111644310e61d
commit: b7383b8b71d49c761480ae9a8b2111644310e61d
branch: main
author: Nikita Sobolev <[email protected]>
committer: pablogsal <[email protected]>
date: 2024-02-26T13:32:27+01:00
summary:
gh-115931: Fix `SyntaxWarning`s in `test_unparse` (#115935)
files:
M Lib/test/test_unparse.py
diff --git a/Lib/test/test_unparse.py b/Lib/test/test_unparse.py
index 77ce18cbf4cbfb..106704ba8c9c2d 100644
--- a/Lib/test/test_unparse.py
+++ b/Lib/test/test_unparse.py
@@ -650,9 +650,18 @@ def test_multiquote_joined_string(self):
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):
_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: [email protected]