~grupoesoc/cubicerp-addons/7.0

« back to all changes in this revision

Viewing changes to report_geraldo/lib/geraldo/site/newsite/site-geraldo/django/core/management/commands/test.py

  • Committer: Cubic ERP
  • Date: 2014-01-07 15:38:09 UTC
  • Revision ID: info@cubicerp.com-20140107153809-4jmif3zoi8rcveve
[ADD] cubicReport

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
from django.core.management.base import BaseCommand
 
2
from optparse import make_option
 
3
import sys
 
4
 
 
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.'),
 
12
    )
 
13
    help = 'Runs the test suite for the specified applications, or the entire site if no apps are specified.'
 
14
    args = '[appname ...]'
 
15
 
 
16
    requires_model_validation = False
 
17
 
 
18
    def handle(self, *test_labels, **options):
 
19
        from django.conf import settings
 
20
 
 
21
        verbosity = int(options.get('verbosity', 1))
 
22
        interactive = options.get('interactive', True)
 
23
    
 
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])
 
28
        else:
 
29
            test_module_name = '.'
 
30
        test_module = __import__(test_module_name, {}, {}, test_path[-1])
 
31
        test_runner = getattr(test_module, test_path[-1])
 
32
 
 
33
        failures = test_runner(test_labels, verbosity=verbosity, interactive=interactive)
 
34
        if failures:
 
35
            sys.exit(failures)