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 @@ -1821,6 +1821,12 @@ def test_get_docstring(self):
18211821 node = ast .parse ('async def foo():\n """spam\n ham"""' )
18221822 self .assertEqual (ast .get_docstring (node .body [0 ]), 'spam\n ham' )
18231823
1824+ node = ast .parse ('async def foo():\n """spam\n ham"""' )
1825+ self .assertEqual (ast .get_docstring (node .body [0 ], clean = False ), 'spam\n ham' )
1826+
1827+ node = ast .parse ('x' )
1828+ self .assertRaises (TypeError , ast .get_docstring , node .body [0 ])
1829+
18241830 def test_get_docstring_none (self ):
18251831 self .assertIsNone (ast .get_docstring (ast .parse ('' )))
18261832 node = ast .parse ('x = "not docstring"' )
@@ -1845,6 +1851,9 @@ def test_get_docstring_none(self):
18451851 node = ast .parse ('async def foo():\n x = "not docstring"' )
18461852 self .assertIsNone (ast .get_docstring (node .body [0 ]))
18471853
1854+ node = ast .parse ('async def foo():\n 42' )
1855+ self .assertIsNone (ast .get_docstring (node .body [0 ]))
1856+
18481857 def test_multi_line_docstring_col_offset_and_lineno_issue16806 (self ):
18491858 node = ast .parse (
18501859 '"""line one\n line two"""\n \n '
You can’t perform that action at this time.
0 commit comments