bpo-38870: Correctly handle empty docstrings in ast.unparse (GH-18768)
Co-authored-by: Pablo Galindo <Pablogsal@gmail.com>
diff --git a/Lib/test/test_unparse.py b/Lib/test/test_unparse.py
index 410df7d..4f57428 100644
--- a/Lib/test/test_unparse.py
+++ b/Lib/test/test_unparse.py
@@ -313,11 +313,18 @@
def test_docstrings(self):
docstrings = (
'this ends with double quote"',
- 'this includes a """triple quote"""'
+ 'this includes a """triple quote"""',
+ '\r',
+ '\\r',
+ '\t',
+ '\\t',
+ '\n',
+ '\\n',
+ '\r\\r\t\\t\n\\n'
)
for docstring in docstrings:
# check as Module docstrings for easy testing
- self.check_ast_roundtrip(f"'{docstring}'")
+ self.check_ast_roundtrip(f"'''{docstring}'''")
def test_constant_tuples(self):
self.check_src_roundtrip(ast.Constant(value=(1,), kind=None), "(1,)")
@@ -390,6 +397,10 @@
empty newline"""''',
'"""With some \t"""',
'"""Foo "bar" baz """',
+ '"""\\r"""',
+ '""""""',
+ '"""\'\'\'"""',
+ '"""\'\'\'\'\'\'"""',
)
for prefix in docstring_prefixes: