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

Jean-Paul Calderone exarkun at twistedmatrix.com
Wed Aug 25 11:24:13 EDT 2010


On Aug 18, 9:20 pm, Margie Roginski <margierogin... at gmail.com> wrote:
> Hi,
>
> 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.
>
> I've searched the doc and even looked at the code, and it seems the
> answer is no, but I'm just wondering if I'm missing something.
>
> Thanks!
>
> Margie

trial (Twisted's test runner) has a `--rterrors` option which causes
it to display errors as soon as they happen.

Jean-Paul



More information about the Python-list mailing list