--- a/web/lib/django/core/management/commands/test.py Wed May 19 17:43:59 2010 +0200
+++ b/web/lib/django/core/management/commands/test.py Tue May 25 02:43:45 2010 +0200
@@ -6,6 +6,8 @@
option_list = BaseCommand.option_list + (
make_option('--noinput', action='store_false', dest='interactive', default=True,
help='Tells Django to NOT prompt the user for input of any kind.'),
+ make_option('--failfast', action='store_true', dest='failfast', default=False,
+ help='Tells Django to stop running the test suite after first failed test.')
)
help = 'Runs the test suite for the specified applications, or the entire site if no apps are specified.'
args = '[appname ...]'
@@ -18,8 +20,21 @@
verbosity = int(options.get('verbosity', 1))
interactive = options.get('interactive', True)
- test_runner = get_runner(settings)
+ failfast = options.get('failfast', False)
+ TestRunner = get_runner(settings)
- failures = test_runner(test_labels, verbosity=verbosity, interactive=interactive)
+ if hasattr(TestRunner, 'func_name'):
+ # Pre 1.2 test runners were just functions,
+ # and did not support the 'failfast' option.
+ import warnings
+ warnings.warn(
+ 'Function-based test runners are deprecated. Test runners should be classes with a run_tests() method.',
+ PendingDeprecationWarning
+ )
+ failures = TestRunner(test_labels, verbosity=verbosity, interactive=interactive)
+ else:
+ test_runner = TestRunner(verbosity=verbosity, interactive=interactive, failfast=failfast)
+ failures = test_runner.run_tests(test_labels)
+
if failures:
- sys.exit(failures)
+ sys.exit(bool(failures))