]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.13] gh-129693: Suppress `SyntaxWarning` in test_fstring (GH-129830) (#130068)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Thu, 13 Feb 2025 02:03:00 +0000 (03:03 +0100)
committerGitHub <noreply@github.com>
Thu, 13 Feb 2025 02:03:00 +0000 (02:03 +0000)
gh-129693: Suppress `SyntaxWarning` in test_fstring (GH-129830)

Suppress SyntaxWarning in test_fstring
(cherry picked from commit 2dd018848ca254047835850b8b95d805cbf7efaf)

Co-authored-by: Tomas R <tomas.roun8@gmail.com>
Lib/test/test_fstring.py

index 6e217ef63be618d8fcc0938f79fd0bac93bbda66..f5111b38a457074d200a4116eb570dc71b05de36 100644 (file)
@@ -1651,8 +1651,9 @@ x = (
         #self.assertEqual(f'X{x =       }Y', 'Xx\t=\t'+repr(x)+'Y')
 
     def test_debug_expressions_are_raw_strings(self):
-
-        self.assertEqual(f'{b"\N{OX}"=}', 'b"\\N{OX}"=b\'\\\\N{OX}\'')
+        with warnings.catch_warnings():
+            warnings.simplefilter('ignore', SyntaxWarning)
+            self.assertEqual(eval("""f'{b"\\N{OX}"=}'"""), 'b"\\N{OX}"=b\'\\\\N{OX}\'')
         self.assertEqual(f'{r"\xff"=}', 'r"\\xff"=\'\\\\xff\'')
         self.assertEqual(f'{r"\n"=}', 'r"\\n"=\'\\\\n\'')
         self.assertEqual(f"{'\''=}", "'\\''=\"'\"")