File tree 1 file changed +9
-0
lines changed
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):
1821
1821
node = ast .parse ('async def foo():\n """spam\n ham"""' )
1822
1822
self .assertEqual (ast .get_docstring (node .body [0 ]), 'spam\n ham' )
1823
1823
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
+
1824
1830
def test_get_docstring_none (self ):
1825
1831
self .assertIsNone (ast .get_docstring (ast .parse ('' )))
1826
1832
node = ast .parse ('x = "not docstring"' )
@@ -1845,6 +1851,9 @@ def test_get_docstring_none(self):
1845
1851
node = ast .parse ('async def foo():\n x = "not docstring"' )
1846
1852
self .assertIsNone (ast .get_docstring (node .body [0 ]))
1847
1853
1854
+ node = ast .parse ('async def foo():\n 42' )
1855
+ self .assertIsNone (ast .get_docstring (node .body [0 ]))
1856
+
1848
1857
def test_multi_line_docstring_col_offset_and_lineno_issue16806 (self ):
1849
1858
node = ast .parse (
1850
1859
'"""line one\n line two"""\n \n '
You can’t perform that action at this time.
0 commit comments