File Lib/unittest/test/test_case.py changed (mode: 100644) (index 045c06464c..e01ac14208) |
... |
... |
class Test_TestCase(unittest.TestCase, TestEquality, TestHashing): |
606 |
606 |
" to get the shortDescription.") |
" to get the shortDescription.") |
607 |
607 |
self.assertEqual(self.shortDescription(), expected_description) |
self.assertEqual(self.shortDescription(), expected_description) |
608 |
608 |
|
|
|
609 |
|
@unittest.skipIf( |
|
610 |
|
sys.flags.optimize >= 2, |
|
611 |
|
"Docstrings are omitted with -O2 and above") |
|
612 |
|
def testShortDescriptionWithSurroundingNewlineOneLineDocstring(self): |
|
613 |
|
""" |
|
614 |
|
Surrounding newlines should be stripped to get the shortDescription. |
|
615 |
|
""" |
|
616 |
|
expected_description = ( |
|
617 |
|
"Surrounding newlines should be stripped" |
|
618 |
|
" to get the shortDescription.") |
|
619 |
|
self.assertEqual(self.shortDescription(), expected_description) |
|
620 |
|
|
|
621 |
|
@unittest.skipIf( |
|
622 |
|
sys.flags.optimize >= 2, |
|
623 |
|
"Docstrings are omitted with -O2 and above") |
|
624 |
|
def testShortDescriptionWithSurroundingNewlineMultiLineDocstring(self): |
|
625 |
|
""" |
|
626 |
|
Surrounding newlines should be stripped to get the shortDescription. |
|
627 |
|
|
|
628 |
|
The specification of how docstring space should be parsed is at |
|
629 |
|
https://www.python.org/dev/peps/pep-0257/#handling-docstring-indentation |
|
630 |
|
which requires that “Blank lines should be removed from the |
|
631 |
|
beginning and end of the docstring.” |
|
632 |
|
|
|
633 |
|
The PEP 257 algorithm is implemented by `pydoc.splitdoc`. |
|
634 |
|
|
|
635 |
|
""" |
|
636 |
|
expected_description = ( |
|
637 |
|
"Surrounding newlines should be stripped" |
|
638 |
|
" to get the shortDescription.") |
|
639 |
|
self.assertEqual(self.shortDescription(), expected_description) |
|
640 |
|
|
609 |
641 |
def testAddTypeEqualityFunc(self): |
def testAddTypeEqualityFunc(self): |
610 |
642 |
class SadSnake(object): |
class SadSnake(object): |
611 |
643 |
"""Dummy class for test_addTypeEqualityFunc.""" |
"""Dummy class for test_addTypeEqualityFunc.""" |
File Lib/unittest/test/test_functiontestcase.py changed (mode: 100644) (index 4bd591209f..d1ec44254c) |
... |
... |
class Test_FunctionTestCase(unittest.TestCase): |
155 |
155 |
expected_description = "Surrounding space should be stripped." |
expected_description = "Surrounding space should be stripped." |
156 |
156 |
self.assertEqual(test.shortDescription(), expected_description) |
self.assertEqual(test.shortDescription(), expected_description) |
157 |
157 |
|
|
|
158 |
|
def test_shortDescription__singleline_docstring_newline_surrounded(self): |
|
159 |
|
""" |
|
160 |
|
Surrounding newlines should be stripped to get the shortDescription. |
|
161 |
|
""" |
|
162 |
|
test_function = (lambda: None) |
|
163 |
|
test_function.__doc__ = """ |
|
164 |
|
Surrounding newlines should be stripped. |
|
165 |
|
""" |
|
166 |
|
test = unittest.FunctionTestCase(test_function) |
|
167 |
|
expected_description = "Surrounding newlines should be stripped." |
|
168 |
|
self.assertEqual(test.shortDescription(), expected_description) |
|
169 |
|
|
|
170 |
|
def test_shortDescription__multiline_docstring_newline_surrounded(self): |
|
171 |
|
""" |
|
172 |
|
Surrounding newlines should be stripped to get the shortDescription. |
|
173 |
|
""" |
|
174 |
|
test_function = (lambda: None) |
|
175 |
|
test_function.__doc__ = """ |
|
176 |
|
Surrounding newlines should be stripped. |
|
177 |
|
|
|
178 |
|
The specification of how docstring space should be parsed is at |
|
179 |
|
https://www.python.org/dev/peps/pep-0257/#handling-docstring-indentation |
|
180 |
|
which requires that “Blank lines should be removed from the |
|
181 |
|
beginning and end of the docstring.” |
|
182 |
|
|
|
183 |
|
""" |
|
184 |
|
test = unittest.FunctionTestCase(test_function) |
|
185 |
|
expected_description = "Surrounding newlines should be stripped." |
|
186 |
|
self.assertEqual(test.shortDescription(), expected_description) |
|
187 |
|
|
158 |
188 |
|
|
159 |
189 |
if __name__ == "__main__": |
if __name__ == "__main__": |
160 |
190 |
unittest.main() |
unittest.main() |