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 @@ -1626,6 +1626,12 @@ def test_get_docstring(self):
1626
1626
node = ast .parse ('async def foo():\n """spam\n ham"""' )
1627
1627
self .assertEqual (ast .get_docstring (node .body [0 ]), 'spam\n ham' )
1628
1628
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
+
1629
1635
def test_get_docstring_none (self ):
1630
1636
self .assertIsNone (ast .get_docstring (ast .parse ('' )))
1631
1637
node = ast .parse ('x = "not docstring"' )
@@ -1650,6 +1656,9 @@ def test_get_docstring_none(self):
1650
1656
node = ast .parse ('async def foo():\n x = "not docstring"' )
1651
1657
self .assertIsNone (ast .get_docstring (node .body [0 ]))
1652
1658
1659
+ node = ast .parse ('async def foo():\n 42' )
1660
+ self .assertIsNone (ast .get_docstring (node .body [0 ]))
1661
+
1653
1662
def test_multi_line_docstring_col_offset_and_lineno_issue16806 (self ):
1654
1663
node = ast .parse (
1655
1664
'"""line one\n line two"""\n \n '
You can’t perform that action at this time.
0 commit comments