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 @@ -1366,6 +1366,12 @@ def test_get_docstring(self):
13661366 node = ast .parse ('async def foo():\n """spam\n ham"""' )
13671367 self .assertEqual (ast .get_docstring (node .body [0 ]), 'spam\n ham' )
13681368
1369+ node = ast .parse ('async def foo():\n """spam\n ham"""' )
1370+ self .assertEqual (ast .get_docstring (node .body [0 ], clean = False ), 'spam\n ham' )
1371+
1372+ node = ast .parse ('x' )
1373+ self .assertRaises (TypeError , ast .get_docstring , node .body [0 ])
1374+
13691375 def test_get_docstring_none (self ):
13701376 self .assertIsNone (ast .get_docstring (ast .parse ('' )))
13711377 node = ast .parse ('x = "not docstring"' )
@@ -1390,6 +1396,9 @@ def test_get_docstring_none(self):
13901396 node = ast .parse ('async def foo():\n x = "not docstring"' )
13911397 self .assertIsNone (ast .get_docstring (node .body [0 ]))
13921398
1399+ node = ast .parse ('async def foo():\n 42' )
1400+ self .assertIsNone (ast .get_docstring (node .body [0 ]))
1401+
13931402 def test_multi_line_docstring_col_offset_and_lineno_issue16806 (self ):
13941403 node = ast .parse (
13951404 '"""line one\n line two"""\n \n '
You can’t perform that action at this time.
0 commit comments