From cbfcc56bbc2d345a33bf38c9358b8a9deefb1735 Mon Sep 17 00:00:00 2001 From: Tomas Roun Date: Fri, 7 Feb 2025 17:14:34 +0100 Subject: [PATCH] Suppress SyntaxWarning in test_fstring --- Lib/test/test_fstring.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Lib/test/test_fstring.py b/Lib/test/test_fstring.py index 1d96b7a2c2459b..f5111b38a45707 100644 --- a/Lib/test/test_fstring.py +++ b/Lib/test/test_fstring.py @@ -15,6 +15,7 @@ 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 @@ def __repr__(self): #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"{'\''=}", "'\\''=\"'\"")