run-tests: make failure reporting in unittest mode equivalent to default
authorGregory Szorc <gregory.szorc@gmail.com>
Mon, 21 Apr 2014 12:15:55 -0700
changeset 21462 8a4ef661f08d
parent 21461 a46a91989d57
child 21463 c908ff887589
run-tests: make failure reporting in unittest mode equivalent to default Unlike unittest's defaults, our result formatter does not print stack traces. Here, we change TestResult.addFailure() to be compatible with the existing/default execution mode.
tests/run-tests.py
--- a/tests/run-tests.py	Sun Apr 20 16:54:51 2014 -0700
+++ b/tests/run-tests.py	Mon Apr 21 12:15:55 2014 -0700
@@ -1067,8 +1067,8 @@
         # sense to map it into fail some day.
         self.warned = []
 
-    def addFailure(self, *args, **kwargs):
-        super(TestResult, self).addFailure(*args, **kwargs)
+    def addFailure(self, test, reason):
+        self.failures.append((test, reason))
 
         if self._options.first:
             self.stop()
@@ -1472,8 +1472,12 @@
                         result.addIgnore(self, str(e))
                     except WarnTest, e:
                         result.addWarn(self, str(e))
-                    except self.failureException:
-                        result.addFailure(self, sys.exc_info())
+                    except self.failureException, e:
+                        # This differs from unittest in that we don't capture
+                        # the stack trace. This is for historical reasons and
+                        # this decision could be revisted in the future,
+                        # especially for PythonTest instances.
+                        result.addFailure(self, str(e))
                     except Exception:
                         result.addError(self, sys.exc_info())
                     else: