]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-129693: Suppress `SyntaxWarning` in test_fstring (#129830)
authorTomas R. <tomas.roun8@gmail.com>
Thu, 13 Feb 2025 00:38:28 +0000 (01:38 +0100)
committerGitHub <noreply@github.com>
Thu, 13 Feb 2025 00:38:28 +0000 (00:38 +0000)
Suppress SyntaxWarning in test_fstring

Lib/test/test_fstring.py

index 1d96b7a2c2459b5d5bdcc771eb76cd84a8b59261..f5111b38a457074d200a4116eb570dc71b05de36 100644 (file)
@@ -15,6 +15,7 @@ import re
 import types
 import decimal
 import unittest
+import warnings
 from test import support
 from test.support.os_helper import temp_cwd
 from test.support.script_helper import assert_python_failure, assert_python_ok
@@ -1650,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"{'\''=}", "'\\''=\"'\"")