How to see intermediate fail results from unittest as tests are running?

Margie Roginski margieroginski at gmail.com
Thu Aug 19 11:45:52 EDT 2010


On Aug 19, 12:41 am, Peter Otten <__pete... at web.de> wrote:
> Margie Roginski wrote:
> > I am using unittest in a fairly basic way, where I have a single file
> > that simply defines a class that inherits from unittest.TestCase and
> > then within that class I have a bunch of methods that start with
> > "test".  Within that file, at the bottom I have:
>
> > if __name__ == "__main__":
> >     unittest.main()
>
> > This works fine and it runs all of the testxx() methods in my file.
> > As it runs it prints if the tests passed or failed, but if they fail,
> > it does not print the details of the assert that made them fail.  It
> > collects this info up and prints it all at the end.
>
> > Ok - my question: Is there any way to get unittest to print the
> > details of the assert that made a test fail, as the tests are
> > running?  IE, after a test fails, I would like to see why, rather than
> > waiting until all the tests are done.
>
> Not exactly what you're asking for, but 2.7 has grown a --failfast option
> that tells unittest to stop on the first failure. For older Python versions
> you can use nose
>
> nosetests -x myscript.py
>
> athttp://somethingaboutorange.com/mrl/projects/nose/0.11.2/
> or the unittest backport athttp://pypi.python.org/pypi/unittest2
>
> Peter

Thanks for the pointers, I will give those a try.

Margie



More information about the Python-list mailing list