From 27e546d028894348c3a038dd1c443d8225cc14c0 Mon Sep 17 00:00:00 2001 From: Lysandros Nikolaou Date: Tue, 20 Jun 2023 15:32:56 +0200 Subject: [PATCH] gh-105915: Fix SyntaxWarning becoming a SyntaxError with -We in test_fstring --- Lib/test/test_fstring.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Lib/test/test_fstring.py b/Lib/test/test_fstring.py index 1eb3bfb41888c2..ba223ae124a8fb 100644 --- a/Lib/test/test_fstring.py +++ b/Lib/test/test_fstring.py @@ -1048,10 +1048,10 @@ def test_fstring_backslash_before_double_bracket(self): 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'\\', '\\')