Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c5c8111

Browse files
[3.12] gh-105915: Fix SyntaxWarning becoming a SyntaxError with -We in test_fstring (GH-105943) (#105945)
(cherry picked from commit 6e40ee6) Co-authored-by: Lysandros Nikolaou <[email protected]>
1 parent e149448 commit c5c8111

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

Lib/test/test_fstring.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1048,10 +1048,10 @@ def test_fstring_backslash_before_double_bracket(self):
10481048
self.assertEqual(fr'{1+1}\}}', '2\\}')
10491049

10501050
def test_fstring_backslash_before_double_bracket_warns_once(self):
1051-
with warnings.catch_warnings(record=True) as w:
1051+
with self.assertWarns(SyntaxWarning) as w:
10521052
eval(r"f'\{{'")
1053-
self.assertEqual(len(w), 1)
1054-
self.assertEqual(w[0].category, SyntaxWarning)
1053+
self.assertEqual(len(w.warnings), 1)
1054+
self.assertEqual(w.warnings[0].category, SyntaxWarning)
10551055

10561056
def test_fstring_backslash_prefix_raw(self):
10571057
self.assertEqual(f'\\', '\\')

0 commit comments

Comments
 (0)