]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.12] gh-105915: Fix SyntaxWarning becoming a SyntaxError with -We in test_fstring...
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Tue, 20 Jun 2023 15:08:29 +0000 (08:08 -0700)
committerGitHub <noreply@github.com>
Tue, 20 Jun 2023 15:08:29 +0000 (15:08 +0000)
(cherry picked from commit 6e40ee6e8456da04d6970a46863300c043c81208)

Co-authored-by: Lysandros Nikolaou <lisandrosnik@gmail.com>
Lib/test/test_fstring.py

index 1eb3bfb41888c20839806bec07bd408551453790..ba223ae124a8fba6b03f28bb01a999993882bd18 100644 (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'\\', '\\')