From: Tomas R. Date: Thu, 13 Feb 2025 00:38:28 +0000 (+0100) Subject: gh-129693: Suppress `SyntaxWarning` in test_fstring (#129830) X-Git-Tag: v3.14.0a6~444 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=2dd018848ca254047835850b8b95d805cbf7efaf;p=thirdparty%2FPython%2Fcpython.git gh-129693: Suppress `SyntaxWarning` in test_fstring (#129830) Suppress SyntaxWarning in test_fstring --- diff --git a/Lib/test/test_fstring.py b/Lib/test/test_fstring.py index 1d96b7a2c245..f5111b38a457 100644 --- a/Lib/test/test_fstring.py +++ b/Lib/test/test_fstring.py @@ -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"{'\''=}", "'\\''=\"'\"")