mirror of
https://github.com/python/cpython.git
synced 2025-12-23 09:19:18 +00:00
gh-135148: Correctly handle f/t strings with comments and debug expressions (#135198)
This commit is contained in:
parent
e89923d366
commit
ef66fb597b
3 changed files with 83 additions and 20 deletions
|
|
@ -1651,6 +1651,18 @@ x = (
|
|||
self.assertEqual(f"{1+2 = # my comment
|
||||
}", '1+2 = \n 3')
|
||||
|
||||
self.assertEqual(f'{""" # booo
|
||||
"""=}', '""" # booo\n """=\' # booo\\n \'')
|
||||
|
||||
self.assertEqual(f'{" # nooo "=}', '" # nooo "=\' # nooo \'')
|
||||
self.assertEqual(f'{" \" # nooo \" "=}', '" \\" # nooo \\" "=\' " # nooo " \'')
|
||||
|
||||
self.assertEqual(f'{ # some comment goes here
|
||||
"""hello"""=}', ' \n """hello"""=\'hello\'')
|
||||
self.assertEqual(f'{"""# this is not a comment
|
||||
a""" # this is a comment
|
||||
}', '# this is not a comment\n a')
|
||||
|
||||
# These next lines contains tabs. Backslash escapes don't
|
||||
# work in f-strings.
|
||||
# patchcheck doesn't like these tabs. So the only way to test
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue