mirror of
https://github.com/python/cpython.git
synced 2025-07-23 19:25:40 +00:00
bpo-39450 Stripped whitespace before parsing the docstring in TestCase.shortDescription (GH-18175)
This commit is contained in:
parent
0f2f35e15f
commit
032de7324e
3 changed files with 12 additions and 1 deletions
|
@ -512,7 +512,7 @@ class TestCase(object):
|
||||||
the specified test method's docstring.
|
the specified test method's docstring.
|
||||||
"""
|
"""
|
||||||
doc = self._testMethodDoc
|
doc = self._testMethodDoc
|
||||||
return doc and doc.split("\n")[0].strip() or None
|
return doc.strip().split("\n")[0].strip() if doc else None
|
||||||
|
|
||||||
|
|
||||||
def id(self):
|
def id(self):
|
||||||
|
|
|
@ -610,6 +610,15 @@ class Test_TestCase(unittest.TestCase, TestEquality, TestHashing):
|
||||||
'Tests shortDescription() for a method with a longer '
|
'Tests shortDescription() for a method with a longer '
|
||||||
'docstring.')
|
'docstring.')
|
||||||
|
|
||||||
|
def testShortDescriptionWhitespaceTrimming(self):
|
||||||
|
"""
|
||||||
|
Tests shortDescription() whitespace is trimmed, so that the first
|
||||||
|
line of nonwhite-space text becomes the docstring.
|
||||||
|
"""
|
||||||
|
self.assertEqual(
|
||||||
|
self.shortDescription(),
|
||||||
|
'Tests shortDescription() whitespace is trimmed, so that the first')
|
||||||
|
|
||||||
def testAddTypeEqualityFunc(self):
|
def testAddTypeEqualityFunc(self):
|
||||||
class SadSnake(object):
|
class SadSnake(object):
|
||||||
"""Dummy class for test_addTypeEqualityFunc."""
|
"""Dummy class for test_addTypeEqualityFunc."""
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
Striped whitespace from docstring before returning it from
|
||||||
|
:func:`unittest.case.shortDescription`.
|
Loading…
Add table
Add a link
Reference in a new issue