summaryrefslogtreecommitdiff
path: root/django/core
diff options
context:
space:
mode:
authorKaren Tracey <kmtracey@gmail.com>2009-12-13 16:24:36 +0000
committerKaren Tracey <kmtracey@gmail.com>2009-12-13 16:24:36 +0000
commit92eec3ef9ae3eed18cef4cb7e87a85df4f06d3f0 (patch)
treeda7ec962435cf1c88397523dbdeb10233f2a5e7d /django/core
parentd10dd3eceb45b72746c974adaf7d9040aa48dd0a (diff)
Fixed #11613: Added a failfast option for test running. Thanks jukvalim and Randy Barlow.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@11843 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django/core')
-rw-r--r--django/core/management/commands/test.py13
1 files changed, 11 insertions, 2 deletions
diff --git a/django/core/management/commands/test.py b/django/core/management/commands/test.py
index 8ebf3daea6..4fd6ba0c8d 100644
--- a/django/core/management/commands/test.py
+++ b/django/core/management/commands/test.py
@@ -6,6 +6,8 @@ class Command(BaseCommand):
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 ...]'
@@ -15,11 +17,18 @@ class Command(BaseCommand):
def handle(self, *test_labels, **options):
from django.conf import settings
from django.test.utils import get_runner
-
+
verbosity = int(options.get('verbosity', 1))
interactive = options.get('interactive', True)
+ failfast = options.get('failfast', False)
test_runner = get_runner(settings)
- failures = test_runner(test_labels, verbosity=verbosity, interactive=interactive)
+ # Some custom test runners won't accept the failfast flag, so let's make sure they accept it before passing it to them
+ if 'failfast' in test_runner.func_code.co_varnames:
+ failures = test_runner(test_labels, verbosity=verbosity, interactive=interactive,
+ failfast=failfast)
+ else:
+ failures = test_runner(test_labels, verbosity=verbosity, interactive=interactive)
+
if failures:
sys.exit(failures)