gh-105915: Fix SyntaxWarning becoming a SyntaxError with -We in test_fstring (#105943)

This commit is contained in:
Lysandros Nikolaou 2023-06-20 16:13:07 +02:00 committed by GitHub
parent 4b431d2e90
commit 6e40ee6e84
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 3 deletions

View File

@ -1048,10 +1048,10 @@ x = (
self.assertEqual(fr'{1+1}\}}', '2\\}')
def test_fstring_backslash_before_double_bracket_warns_once(self):
with warnings.catch_warnings(record=True) as w:
with self.assertWarns(SyntaxWarning) as w:
eval(r"f'\{{'")
self.assertEqual(len(w), 1)
self.assertEqual(w[0].category, SyntaxWarning)
self.assertEqual(len(w.warnings), 1)
self.assertEqual(w.warnings[0].category, SyntaxWarning)
def test_fstring_backslash_prefix_raw(self):
self.assertEqual(f'\\', '\\')