[Zodb-checkins] CVS: StandaloneZODB - test.py:1.11
Jeremy Hylton
jeremy@zope.com
Mon, 21 Jan 2002 15:57:15 -0500
Update of /cvs-repository/StandaloneZODB
In directory cvs.zope.org:/tmp/cvs-serv6572
Modified Files:
test.py
Log Message:
Add ImmediateTestRunner that prints a traceback when the error occurs.
=== StandaloneZODB/test.py 1.10 => 1.11 ===
return None
+import traceback
+
+class ImmediateTestResult(unittest._TextTestResult):
+
+ def _print_traceback(self, msg, err):
+ if self.showAll or self.dots:
+ self.stream.writeln("\n")
+
+ self.stream.writeln(msg)
+ self.stream.writeln(''.join(traceback.format_exception(*err)))
+
+
+ def addError(self, test, err):
+ self._print_traceback("Error in test %s" % test, err)
+
+ def addFailure(self, test, err):
+ self._print_traceback("Failure in test %s" % test, err)
+
+class ImmediateTestRunner(unittest.TextTestRunner):
+
+ def _makeResult(self):
+ return ImmediateTestResult(self.stream, self.descriptions, self.verbosity)
+
def main(filter=None):
setup_path()
files = find_tests(filter)
@@ -143,14 +166,14 @@
continue
suites.append(suite)
if suites:
- runner = unittest.TextTestRunner(verbosity=VERBOSE)
+ runner = ImmediateTestRunner(verbosity=VERBOSE)
while 1:
for suite in suites:
runner.run(suite)
gc.collect()
check_mem()
else:
- runner = unittest.TextTestRunner(verbosity=VERBOSE)
+ runner = ImmediateTestRunner(verbosity=VERBOSE)
if MERGE_SUITES:
suite = unittest.TestSuite()
for file in files: