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):