Skip to content

Commit 2dd0188

Browse files
authored
gh-129693: Suppress SyntaxWarning in test_fstring (#129830)
Suppress SyntaxWarning in test_fstring
1 parent e094420 commit 2dd0188

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

Lib/test/test_fstring.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import types
1616
import decimal
1717
import unittest
18+
import warnings
1819
from test import support
1920
from test.support.os_helper import temp_cwd
2021
from test.support.script_helper import assert_python_failure, assert_python_ok
@@ -1650,8 +1651,9 @@ def __repr__(self):
16501651
#self.assertEqual(f'X{x = }Y', 'Xx\t=\t'+repr(x)+'Y')
16511652

16521653
def test_debug_expressions_are_raw_strings(self):
1653-
1654-
self.assertEqual(f'{b"\N{OX}"=}', 'b"\\N{OX}"=b\'\\\\N{OX}\'')
1654+
with warnings.catch_warnings():
1655+
warnings.simplefilter('ignore', SyntaxWarning)
1656+
self.assertEqual(eval("""f'{b"\\N{OX}"=}'"""), 'b"\\N{OX}"=b\'\\\\N{OX}\'')
16551657
self.assertEqual(f'{r"\xff"=}', 'r"\\xff"=\'\\\\xff\'')
16561658
self.assertEqual(f'{r"\n"=}', 'r"\\n"=\'\\\\n\'')
16571659
self.assertEqual(f"{'\''=}", "'\\''=\"'\"")

0 commit comments

Comments
 (0)