diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2023-06-20 15:08:29 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-06-20 15:08:29 (GMT) |
commit | c5c8111acf2a3a62ee06567593c78e8d5229fc79 (patch) | |
tree | 42690395d1477320d1b33fcac952f27d9f40944f /Lib/test/test_fstring.py | |
parent | e149448595d9099d54a4f4603e6dd3864e81b6b8 (diff) | |
download | cpython-c5c8111acf2a3a62ee06567593c78e8d5229fc79.zip cpython-c5c8111acf2a3a62ee06567593c78e8d5229fc79.tar.gz cpython-c5c8111acf2a3a62ee06567593c78e8d5229fc79.tar.bz2 |
[3.12] gh-105915: Fix SyntaxWarning becoming a SyntaxError with -We in test_fstring (GH-105943) (#105945)
(cherry picked from commit 6e40ee6e8456da04d6970a46863300c043c81208)
Co-authored-by: Lysandros Nikolaou <lisandrosnik@gmail.com>
Diffstat (limited to 'Lib/test/test_fstring.py')
-rw-r--r-- | Lib/test/test_fstring.py | 6 |
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'\\', '\\') |