tests/run-tests.py
changeset 21429 203ed3cf6c81
parent 21428 3df2ecf8d545
child 21430 cf2992656bf8
--- a/tests/run-tests.py	Sun Apr 20 11:29:39 2014 -0700
+++ b/tests/run-tests.py	Sun Apr 20 11:47:40 2014 -0700
@@ -982,6 +982,19 @@
 
 iolock = threading.Lock()
 
+class TestResult(unittest._TextTestResult):
+    """Holds results when executing via unittest."""
+    # Don't worry too much about accessing the non-public _TextTestResult.
+    # It is relatively common in Python testing tools.
+    def __init__(self, *args, **kwargs):
+        super(TestResult, self).__init__(*args, **kwargs)
+
+class TextTestRunner(unittest.TextTestRunner):
+    """Custom unittest test runner that uses appropriate settings."""
+
+    def _makeResult(self):
+        return TestResult(self.stream, self.descriptions, self.verbosity)
+
 class TestRunner(object):
     """Holds context for executing tests.
 
@@ -1191,7 +1204,7 @@
                 verbosity = 1
                 if self.options.verbose:
                     verbosity = 2
-                runner = unittest.TextTestRunner(verbosity=verbosity)
+                runner = TextTestRunner(verbosity=verbosity)
                 runner.run(suite)
             else:
                 self._executetests(tests)