Skip to content

Commit

Permalink
pythongh-105915: Fix SyntaxWarning becoming a SyntaxError with -We in…
Browse files Browse the repository at this point in the history
… test_fstring (pythonGH-105943)

(cherry picked from commit 6e40ee6)

Co-authored-by: Lysandros Nikolaou <lisandrosnik@gmail.com>
  • Loading branch information
lysnikolaou authored and miss-islington committed Jun 20, 2023
1 parent e149448 commit d13be4d
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions Lib/test/test_fstring.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'\\', '\\')
Expand Down

0 comments on commit d13be4d

Please sign in to comment.