print unittest errors immediately 
Author Message
 print unittest errors immediately

I've wasted a lot of time waiting for unittests to finish running so
that I can see a traceback raised during the first test.  As often as
not, I'll see many errors all caused by the same bug.  To avoid
wasting so much time, I wrote a little extension to the TextTestRunner
that prints the error immediately instead of at the end.

If you've frittered away hours watching dots march across your screen
waiting for the traceback, I hope you'll find this little bit of code


import traceback
import unittest

class ImmediateTestResult(unittest._TextTestResult):

    def _print_traceback(self, msg, err):
        if self.showAll or self.dots:

    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.descriptions,

Sat, 10 Jul 2004 05:21:14 GMT  
 [ 1 post ] 

 Relevant Pages 

1. Don't want to leave the shell immediately on error

2. ERROR TERM/0 Print error (COM1)

3. Error TERM / 0 Print error

4. Error TERM / 0 Print error

5. Error Term/0 Print error - - - - - - Who can Help.

6. unittest: how to specify which suites to run with unittest.main()?

7. Need help Translating Python unittest to Ruby Test::Unit

8. The various UnitTest frameworks.

9. Windows python 2.2.1 IDLE glitch - unittest output display nothing

10. problems redirecting unittest output to sys.stdout

11. Code Coverage support for unittest?

12. Tkinter and unittest


Powered by phpBB® Forum Software