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 @@ -1366,6 +1366,12 @@ def test_get_docstring(self):
1366
1366
node = ast .parse ('async def foo():\n """spam\n ham"""' )
1367
1367
self .assertEqual (ast .get_docstring (node .body [0 ]), 'spam\n ham' )
1368
1368
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
+
1369
1375
def test_get_docstring_none (self ):
1370
1376
self .assertIsNone (ast .get_docstring (ast .parse ('' )))
1371
1377
node = ast .parse ('x = "not docstring"' )
@@ -1390,6 +1396,9 @@ def test_get_docstring_none(self):
1390
1396
node = ast .parse ('async def foo():\n x = "not docstring"' )
1391
1397
self .assertIsNone (ast .get_docstring (node .body [0 ]))
1392
1398
1399
+ node = ast .parse ('async def foo():\n 42' )
1400
+ self .assertIsNone (ast .get_docstring (node .body [0 ]))
1401
+
1393
1402
def test_multi_line_docstring_col_offset_and_lineno_issue16806 (self ):
1394
1403
node = ast .parse (
1395
1404
'"""line one\n line two"""\n \n '
You can’t perform that action at this time.
0 commit comments