summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLysandros Nikolaou <lisandrosnik@gmail.com>2023-06-20 14:13:07 (GMT)
committerGitHub <noreply@github.com>2023-06-20 14:13:07 (GMT)
commit6e40ee6e8456da04d6970a46863300c043c81208 (patch)
treeba2c554318da5751d7a38ebc1207df8525f11f27
parent4b431d2e90bf5760a57aa40af2dd78e7bbf0b1ae (diff)
downloadcpython-6e40ee6e8456da04d6970a46863300c043c81208.zip
cpython-6e40ee6e8456da04d6970a46863300c043c81208.tar.gz
cpython-6e40ee6e8456da04d6970a46863300c043c81208.tar.bz2
gh-105915: Fix SyntaxWarning becoming a SyntaxError with -We in test_fstring (#105943)
-rw-r--r--Lib/test/test_fstring.py6
1 files changed, 3 insertions, 3 deletions
diff --git a/Lib/test/test_fstring.py b/Lib/test/test_fstring.py
index 1eb3bfb..ba223ae 100644
--- a/Lib/test/test_fstring.py
+++ b/Lib/test/test_fstring.py
@@ -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'\\', '\\')