diff options
Diffstat (limited to 'Lib/unittest/case.py')
-rw-r--r-- | Lib/unittest/case.py | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/Lib/unittest/case.py b/Lib/unittest/case.py index e8ebc90..66f414f 100644 --- a/Lib/unittest/case.py +++ b/Lib/unittest/case.py @@ -216,18 +216,15 @@ class TestCase(object): return result.TestResult() def shortDescription(self): - """Returns both the test method name and first line of its docstring. + """Returns a one-line description of the test, or None if no + description has been provided. - If no docstring is given, only returns the method name. + The default implementation of this method returns the first line of + the specified test method's docstring. """ - desc = str(self) - doc_first_line = None + doc = self._testMethodDoc + return doc and doc.split("\n")[0].strip() or None - if self._testMethodDoc: - doc_first_line = self._testMethodDoc.split("\n")[0].strip() - if doc_first_line: - desc = '\n'.join((desc, doc_first_line)) - return desc def id(self): return "%s.%s" % (util.strclass(self.__class__), self._testMethodName) @@ -488,7 +485,6 @@ class TestCase(object): assertNotEquals = assertNotEqual assertAlmostEquals = assertAlmostEqual assertNotAlmostEquals = assertNotAlmostEqual - assert_ = assertTrue # These fail* assertion method names are pending deprecation and will # be a DeprecationWarning in 3.2; http://bugs.python.org/issue2578 @@ -505,6 +501,7 @@ class TestCase(object): failUnlessAlmostEqual = _deprecate(assertAlmostEqual) failIfAlmostEqual = _deprecate(assertNotAlmostEqual) failUnless = _deprecate(assertTrue) + assert_ = _deprecate(assertTrue) failUnlessRaises = _deprecate(assertRaises) failIf = _deprecate(assertFalse) |