mirror of
https://github.com/python/cpython.git
synced 2025-08-09 19:38:42 +00:00
[3.12] gh-108843: fix ast.unparse for f-string with many quotes (GH-108981) (#109541)
gh-108843: fix ast.unparse for f-string with many quotes (GH-108981)
(cherry picked from commit 23f9f6f464
)
Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com>
This commit is contained in:
parent
f6fc831aa9
commit
2401b980da
3 changed files with 35 additions and 1 deletions
|
@ -635,6 +635,20 @@ class CosmeticTestCase(ASTTestCase):
|
|||
self.check_src_roundtrip("[a, b] = [c, d] = [e, f] = g")
|
||||
self.check_src_roundtrip("a, b = [c, d] = e, f = g")
|
||||
|
||||
def test_multiquote_joined_string(self):
|
||||
self.check_ast_roundtrip("f\"'''{1}\\\"\\\"\\\"\" ")
|
||||
self.check_ast_roundtrip("""f"'''{1}""\\"" """)
|
||||
self.check_ast_roundtrip("""f'""\"{1}''' """)
|
||||
self.check_ast_roundtrip("""f'""\"{1}""\\"' """)
|
||||
|
||||
self.check_ast_roundtrip("""f"'''{"\\n"}""\\"" """)
|
||||
self.check_ast_roundtrip("""f'""\"{"\\n"}''' """)
|
||||
self.check_ast_roundtrip("""f'""\"{"\\n"}""\\"' """)
|
||||
|
||||
self.check_ast_roundtrip("""f'''""\"''\\'{"\\n"}''' """)
|
||||
self.check_ast_roundtrip("""f'''""\"''\\'{"\\n\\"'"}''' """)
|
||||
self.check_ast_roundtrip("""f'''""\"''\\'{""\"\\n\\"'''""\" '''\\n'''}''' """)
|
||||
|
||||
|
||||
class ManualASTCreationTestCase(unittest.TestCase):
|
||||
"""Test that AST nodes created without a type_params field unparse correctly."""
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue