Thanks to visit codestin.com
Credit goes to github.com

Skip to content

gh-129693: Suppress SyntaxWarning in test_fstring #129830

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 13, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions Lib/test/test_fstring.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"{'\''=}", "'\\''=\"'\"")
Expand Down
Loading