9
9
from collections import defaultdict
10
10
from collections .abc import Sequence
11
11
from functools import partial
12
- from textwrap import dedent
13
12
from typing import List
14
13
from typing import Optional
15
14
from typing import Tuple
@@ -1247,7 +1246,7 @@ def write_fixture(fixture_def):
1247
1246
else :
1248
1247
funcargspec = argname
1249
1248
tw .line (funcargspec , green = True )
1250
- fixture_doc = fixture_def .func . __doc__
1249
+ fixture_doc = inspect . getdoc ( fixture_def .func )
1251
1250
if fixture_doc :
1252
1251
write_docstring (tw , fixture_doc )
1253
1252
else :
@@ -1332,7 +1331,7 @@ def _showfixtures_main(config, session):
1332
1331
tw .write (" -- %s" % bestrel , yellow = True )
1333
1332
tw .write ("\n " )
1334
1333
loc = getlocation (fixturedef .func , curdir )
1335
- doc = fixturedef .func . __doc__ or ""
1334
+ doc = inspect . getdoc ( fixturedef .func )
1336
1335
if doc :
1337
1336
write_docstring (tw , doc )
1338
1337
else :
@@ -1341,18 +1340,8 @@ def _showfixtures_main(config, session):
1341
1340
1342
1341
1343
1342
def write_docstring (tw , doc , indent = " " ):
1344
- doc = doc .rstrip ()
1345
- if "\n " in doc :
1346
- firstline , rest = doc .split ("\n " , 1 )
1347
- else :
1348
- firstline , rest = doc , ""
1349
-
1350
- if firstline .strip ():
1351
- tw .line (indent + firstline .strip ())
1352
-
1353
- if rest :
1354
- for line in dedent (rest ).split ("\n " ):
1355
- tw .write (indent + line + "\n " )
1343
+ for line in doc .split ("\n " ):
1344
+ tw .write (indent + line + "\n " )
1356
1345
1357
1346
1358
1347
class Function (PyobjMixin , nodes .Item ):
0 commit comments