diff --git a/product/ERP5Type/tests/ERP5TypeTestCase.py b/product/ERP5Type/tests/ERP5TypeTestCase.py index 3d3ab8d9b1ca71374036e27241b39b9448b876de..94778cb9f65c4251c8c12526181f5b516eb68112 100644 --- a/product/ERP5Type/tests/ERP5TypeTestCase.py +++ b/product/ERP5Type/tests/ERP5TypeTestCase.py @@ -226,13 +226,6 @@ class ERP5TypeTestCaseMixin(ProcessingNodeTestCase, PortalTestCase): ZopeTestCase._print('All tests are skipped when --save option is passed ' 'with --update_business_templates or without --load') - def shortDescription(self): - description = str(self) - doc = self._testMethodDoc - if doc and doc.split("\n")[0].strip(): - description += ', ' + doc.split("\n")[0].strip() - return description - def getRevision(self): erp5_path = os.path.join(instancehome, 'Products', 'ERP5') try: diff --git a/product/ERP5Type/tests/backportUnittest.py b/product/ERP5Type/tests/backportUnittest.py index 4f63363cd2e31fb637c5193b76d6e6e5986e31d4..8f126a30678c6876751015165a3ddd6501355045 100644 --- a/product/ERP5Type/tests/backportUnittest.py +++ b/product/ERP5Type/tests/backportUnittest.py @@ -189,27 +189,6 @@ if not hasattr(unittest.TestResult, 'addSkip'): # BBB: Python < 2.7 def addSkip(self, test, reason): """Called when a test is skipped.""" self.skipped.append((test, reason)) - - def addExpectedFailure(self, test, err): - """Called when an expected failure/error occured.""" - self.expectedFailures.append( - (test, self._exc_info_to_string(err, test))) - - def addUnexpectedSuccess(self, test): - """Called when a test was expected to fail, but succeed.""" - self.unexpectedSuccesses.append(test) - - for f in __init__, addSkip, addExpectedFailure, addUnexpectedSuccess: - setattr(unittest.TestResult, f.__name__, f) - -class _TextTestResult(unittest._TextTestResult): - - def wasSuccessful(self): - "Tells whether or not this result was a success" - return not (self.failures or self.errors or self.unexpectedSuccesses) - - def addSkip(self, test, reason): - super(_TextTestResult, self).addSkip(test, reason) if self.showAll: self.stream.writeln("skipped %s" % repr(reason)) elif self.dots: @@ -217,7 +196,9 @@ class _TextTestResult(unittest._TextTestResult): self.stream.flush() def addExpectedFailure(self, test, err): - super(_TextTestResult, self).addExpectedFailure(test, err) + """Called when an expected failure/error occured.""" + self.expectedFailures.append( + (test, self._exc_info_to_string(err, test))) if self.showAll: self.stream.writeln("expected failure") elif self.dots: @@ -225,13 +206,32 @@ class _TextTestResult(unittest._TextTestResult): self.stream.flush() def addUnexpectedSuccess(self, test): - super(_TextTestResult, self).addUnexpectedSuccess(test) + """Called when a test was expected to fail, but succeed.""" + self.unexpectedSuccesses.append(test) if self.showAll: self.stream.writeln("unexpected success") elif self.dots: self.stream.write("u") self.stream.flush() + for f in __init__, addSkip, addExpectedFailure, addUnexpectedSuccess: + setattr(unittest.TestResult, f.__name__, f) + + def getDescription(self, test): + doc_first_line = test.shortDescription() + if self.descriptions and doc_first_line: + return '\n'.join((str(test), doc_first_line)) + else: + return str(test) + + unittest._TextTestResult.getDescription = getDescription + +class _TextTestResult(unittest._TextTestResult): + + def wasSuccessful(self): + "Tells whether or not this result was a success" + return not (self.failures or self.errors or self.unexpectedSuccesses) + def printErrors(self): if self.dots or self.showAll: self.stream.writeln()