Django

Code

Show
Ignore:
Timestamp:
08/02/07 16:51:32 (1 year ago)
Author:
danderson
Message:

schema-evolution: updated from trunk/HEAD (r5787)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/branches/schema-evolution/tests/runtests.py

    r5734 r5788  
    7474        self.assert_(not missing, "Missing Errors: " + '\n'.join(missing)) 
    7575 
    76 def django_tests(verbosity, tests_to_run): 
     76def django_tests(verbosity, interactive, test_labels): 
    7777    from django.conf import settings 
    7878 
     
    110110            # no models were named (i.e., run all), import 
    111111            # this model and add it to the list to test. 
    112             if not tests_to_run or model_name in tests_to_run
     112            if not test_labels or model_name in set([label.split('.')[0] for label in test_labels])
    113113                if verbosity >= 1: 
    114114                    print "Importing model %s" % model_name 
     
    117117                    if model_label not in settings.INSTALLED_APPS: 
    118118                        settings.INSTALLED_APPS.append(model_label) 
    119                     test_models.append(mod) 
    120119        except Exception, e: 
    121120            sys.stderr.write("Error while importing %s:" % model_name + ''.join(traceback.format_exception(*sys.exc_info())[1:])) 
     
    126125    for model_dir, model_name in get_invalid_models(): 
    127126        model_label = '.'.join([model_dir, model_name]) 
    128         if not tests_to_run or model_name in tests_to_run
     127        if not test_labels or model_name in test_labels
    129128            extra_tests.append(InvalidModelTestCase(model_label)) 
    130129 
    131130    # Run the test suite, including the extra validation tests. 
    132131    from django.test.simple import run_tests 
    133     failures = run_tests(test_models, verbosity, extra_tests=extra_tests) 
     132    failures = run_tests(test_labels, verbosity=verbosity, interactive=interactive, extra_tests=extra_tests) 
    134133    if failures: 
    135134        sys.exit(failures) 
     
    150149        type='choice', choices=['0', '1', '2'], 
    151150        help='Verbosity level; 0=minimal output, 1=normal output, 2=all output') 
     151    parser.add_option('--noinput', action='store_false', dest='interactive', default=True, 
     152        help='Tells Django to NOT prompt the user for input of any kind.') 
    152153    parser.add_option('--settings', 
    153154        help='Python path to settings module, e.g. "myproject.settings". If this isn\'t provided, the DJANGO_SETTINGS_MODULE environment variable will be used.') 
     
    158159        parser.error("DJANGO_SETTINGS_MODULE is not set in the environment. " 
    159160                      "Set it or use --settings.") 
    160     django_tests(int(options.verbosity), args) 
     161    django_tests(int(options.verbosity), options.interactive, args)