[TIP] Fail-fast testing?

J. Cliff Dyer jcd at sdf.lonestar.org
Fri Mar 5 08:40:30 PST 2010

Would it be possible to get something like the fail-fast features that
have been incorporated into django 1.2 included in unittest somehow?  

There are two improvements that I think could be generally useful.

http://code.djangoproject.com/changeset/12034 provides a Ctrl-C override
(using the signals module), which prevents the test runner from dying
with an exception on Ctrl-C, and instead finishes the current test, and
returns the results up to that point.  The output looks like this:

$ ./manage.py test
[Snipped test setup]
.........................^C <Test run halted by Ctrl-C> .
Ran 26 tests in 1.488s

Destroying test database 'default'...

http://code.djangoproject.com/changeset/11843 provides a --failfast
option which exits the test run after the first failure, showing all
test output up to that point.  Both of these are great options to have
available when working with large test suites.

I'd be happy to put in some legwork if there were interest in having
this functionality available in unittest.


More information about the testing-in-python mailing list