mirror of
https://github.com/python/cpython.git
synced 2025-08-10 20:08:47 +00:00
[3.12] gh-105915: Fix SyntaxWarning becoming a SyntaxError with -We in test_fstring (GH-105943) (#105945)
(cherry picked from commit 6e40ee6e84
)
Co-authored-by: Lysandros Nikolaou <lisandrosnik@gmail.com>
This commit is contained in:
parent
e149448595
commit
c5c8111acf
1 changed files with 3 additions and 3 deletions
|
@ -1048,10 +1048,10 @@ x = (
|
||||||
self.assertEqual(fr'{1+1}\}}', '2\\}')
|
self.assertEqual(fr'{1+1}\}}', '2\\}')
|
||||||
|
|
||||||
def test_fstring_backslash_before_double_bracket_warns_once(self):
|
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'\{{'")
|
eval(r"f'\{{'")
|
||||||
self.assertEqual(len(w), 1)
|
self.assertEqual(len(w.warnings), 1)
|
||||||
self.assertEqual(w[0].category, SyntaxWarning)
|
self.assertEqual(w.warnings[0].category, SyntaxWarning)
|
||||||
|
|
||||||
def test_fstring_backslash_prefix_raw(self):
|
def test_fstring_backslash_prefix_raw(self):
|
||||||
self.assertEqual(f'\\', '\\')
|
self.assertEqual(f'\\', '\\')
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue