[issue8074] Fail-fast behavior for unittest
Cliff Dyer
report at bugs.python.org
Fri Mar 5 18:32:24 CET 2010
New submission from Cliff Dyer <jcd at sdf.lonestar.org>:
When a long suite of tests is running, it would be nice to be able to exit out early to see the results of the tests that have run so far.
I would like to see a couple of features included in `unittest` to this effect that have recently been implemented in django's test runner. The first exits gracefully on `^C`, the second allows the user to specify a `--failfast` option, which causes the test runner to exit after the first failure or error, rather than proceeding with the
If you hit `^C`, rather than exit with a stack trace of whatever was happening at the time, `unittest` should complete the current test, and then exit with the results to that point. A second `^C` would be treated as a normal `KeyboardInterrupt`, in case that last test were somehow running on too long.
{{{
$ python test_module.py
..F.s.^C <Test run halted by Ctrl-C> x
======================================================================
FAIL: test_multiline_equal (__main__.MyTest)
Unicode objects return diffs on failure
----------------------------------------------------------------------
Traceback (most recent call last):
File "test_test.py", line 39, in test_multiline_equal
self.assertEqual(original, revised)
AssertionError:
- Lorem ipsum dolor sit amet,
? ^
+ Lorem ipsum color sit amet,
? ^
consectetur adipisicing elit,
+ that's the way the cookie crumbles,
sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
----------------------------------------------------------------------
Ran 7 tests in 12.010s
FAILED (failures=1, skipped=1, expected failures=1)
}}}
A `failfast` option could be specified as a keyword argument to `unittest.main()`, or `unittest.main()` could read it off the command line, according to the same mechanism used by, e.g., the `verbosity` option.
----------
components: Library (Lib)
messages: 100493
nosy: jcd
severity: normal
status: open
title: Fail-fast behavior for unittest
type: feature request
versions: Python 2.7, Python 3.1, Python 3.2, Python 3.3
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue8074>
_______________________________________
More information about the Python-bugs-list
mailing list