File tree Expand file tree Collapse file tree 1 file changed +9
-0
lines changed Expand file tree Collapse file tree 1 file changed +9
-0
lines changed Original file line number Diff line number Diff line change @@ -1626,6 +1626,12 @@ def test_get_docstring(self):
16261626 node = ast .parse ('async def foo():\n """spam\n ham"""' )
16271627 self .assertEqual (ast .get_docstring (node .body [0 ]), 'spam\n ham' )
16281628
1629+ node = ast .parse ('async def foo():\n """spam\n ham"""' )
1630+ self .assertEqual (ast .get_docstring (node .body [0 ], clean = False ), 'spam\n ham' )
1631+
1632+ node = ast .parse ('x' )
1633+ self .assertRaises (TypeError , ast .get_docstring , node .body [0 ])
1634+
16291635 def test_get_docstring_none (self ):
16301636 self .assertIsNone (ast .get_docstring (ast .parse ('' )))
16311637 node = ast .parse ('x = "not docstring"' )
@@ -1650,6 +1656,9 @@ def test_get_docstring_none(self):
16501656 node = ast .parse ('async def foo():\n x = "not docstring"' )
16511657 self .assertIsNone (ast .get_docstring (node .body [0 ]))
16521658
1659+ node = ast .parse ('async def foo():\n 42' )
1660+ self .assertIsNone (ast .get_docstring (node .body [0 ]))
1661+
16531662 def test_multi_line_docstring_col_offset_and_lineno_issue16806 (self ):
16541663 node = ast .parse (
16551664 '"""line one\n line two"""\n \n '
You can’t perform that action at this time.
0 commit comments