1
from django.core.management.base import BaseCommand
2
from optparse import make_option
5
class Command(BaseCommand):
6
option_list = BaseCommand.option_list + (
7
make_option('--verbosity', action='store', dest='verbosity', default='1',
8
type='choice', choices=['0', '1', '2'],
9
help='Verbosity level; 0=minimal output, 1=normal output, 2=all output'),
10
make_option('--noinput', action='store_false', dest='interactive', default=True,
11
help='Tells Django to NOT prompt the user for input of any kind.'),
13
help = 'Runs the test suite for the specified applications, or the entire site if no apps are specified.'
14
args = '[appname ...]'
16
requires_model_validation = False
18
def handle(self, *test_labels, **options):
19
from django.conf import settings
21
verbosity = int(options.get('verbosity', 1))
22
interactive = options.get('interactive', True)
24
test_path = settings.TEST_RUNNER.split('.')
25
# Allow for Python 2.5 relative paths
26
if len(test_path) > 1:
27
test_module_name = '.'.join(test_path[:-1])
29
test_module_name = '.'
30
test_module = __import__(test_module_name, {}, {}, test_path[-1])
31
test_runner = getattr(test_module, test_path[-1])
33
failures = test_runner(test_labels, verbosity=verbosity, interactive=interactive)