2007-08-16 14:06:55 +08:00
|
|
|
from django.core.management.base import BaseCommand
|
2007-09-10 05:57:59 +08:00
|
|
|
from optparse import make_option
|
2007-08-16 19:06:49 +08:00
|
|
|
import sys
|
2007-08-16 14:06:55 +08:00
|
|
|
|
|
|
|
class Command(BaseCommand):
|
2007-09-10 05:57:59 +08:00
|
|
|
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.'),
|
|
|
|
)
|
2007-08-16 14:06:55 +08:00
|
|
|
help = 'Runs the test suite for the specified applications, or the entire site if no apps are specified.'
|
2007-09-10 05:57:59 +08:00
|
|
|
args = '[appname ...]'
|
2007-08-16 14:06:55 +08:00
|
|
|
|
|
|
|
requires_model_validation = False
|
|
|
|
|
|
|
|
def handle(self, *test_labels, **options):
|
|
|
|
from django.conf import settings
|
|
|
|
|
2007-08-17 08:11:56 +08:00
|
|
|
verbosity = int(options.get('verbosity', 1))
|
2007-08-16 14:06:55 +08:00
|
|
|
interactive = options.get('interactive', True)
|
2008-10-02 20:57:13 +08:00
|
|
|
|
2007-08-16 14:06:55 +08:00
|
|
|
test_path = settings.TEST_RUNNER.split('.')
|
|
|
|
# Allow for Python 2.5 relative paths
|
|
|
|
if len(test_path) > 1:
|
|
|
|
test_module_name = '.'.join(test_path[:-1])
|
|
|
|
else:
|
|
|
|
test_module_name = '.'
|
|
|
|
test_module = __import__(test_module_name, {}, {}, test_path[-1])
|
|
|
|
test_runner = getattr(test_module, test_path[-1])
|
|
|
|
|
|
|
|
failures = test_runner(test_labels, verbosity=verbosity, interactive=interactive)
|
|
|
|
if failures:
|
|
|
|
sys.exit(failures)
|