Reputation: 33
unittest.shortDescription()
returns only the first line of the test method's docstring.
Is there a way to change this behavior, e.g. to display the entirety of the docstring, or to display another message ?
Would I need to override shortDescription()
?
EDIT: I did know that shortDescription() takes no arguments (besides the implicit object reference), but I was very unclear in the wording of my question. What I'm really looking for is pointers to how to override shortDescription() and get at, say, the entire contents of the docstring. Thanks !
Upvotes: 1
Views: 437
Reputation: 765
Override shortDescription() in your test class as follows:
Class Foo(unittest.TestCase):
def shortDescription(self):
doc = self._testMethodDoc
return doc or None
Upvotes: 1
Reputation: 1180
unittest.shortDescription()
takes no arguments. You would have to override it to get the entire docstring.
Upvotes: 0