File tree 3 files changed +12
-1
lines changed 3 files changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -529,7 +529,7 @@ def shortDescription(self):
529
529
the specified test method's docstring.
530
530
"""
531
531
doc = self ._testMethodDoc
532
- return doc and doc . split ("\n " )[0 ].strip () or None
532
+ return doc . strip (). split ("\n " )[0 ].strip () if doc else None
533
533
534
534
535
535
def id (self ):
Original file line number Diff line number Diff line change @@ -610,6 +610,15 @@ def testShortDescriptionWithMultiLineDocstring(self):
610
610
'Tests shortDescription() for a method with a longer '
611
611
'docstring.' )
612
612
613
+ def testShortDescriptionWhitespaceTrimming (self ):
614
+ """
615
+ Tests shortDescription() whitespace is trimmed, so that the first
616
+ line of nonwhite-space text becomes the docstring.
617
+ """
618
+ self .assertEqual (
619
+ self .shortDescription (),
620
+ 'Tests shortDescription() whitespace is trimmed, so that the first' )
621
+
613
622
def testAddTypeEqualityFunc (self ):
614
623
class SadSnake (object ):
615
624
"""Dummy class for test_addTypeEqualityFunc."""
Original file line number Diff line number Diff line change
1
+ Striped whitespace from docstring before returning it from
2
+ :func: `unittest.case.shortDescription `.
You can’t perform that action at this time.
0 commit comments