web/lib/django/core/management/commands/test.py
changeset 0 0d40e90630ef
child 29 cc9b7e14412b
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/web/lib/django/core/management/commands/test.py	Wed Jan 20 00:34:04 2010 +0100
@@ -0,0 +1,25 @@
+from django.core.management.base import BaseCommand
+from optparse import make_option
+import sys
+
+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.'),
+    )
+    help = 'Runs the test suite for the specified applications, or the entire site if no apps are specified.'
+    args = '[appname ...]'
+
+    requires_model_validation = False
+
+    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)
+        test_runner = get_runner(settings)
+
+        failures = test_runner(test_labels, verbosity=verbosity, interactive=interactive)
+        if failures:
+            sys.exit(failures)