Ticket #12574: 12574.diff

File 12574.diff, 1.7 KB (added by ramiro, 6 years ago)

Same patch plus moving calculation of the set of test outside of a loop

  • tests/runtests.py

    diff -r 0b171fe8b1bc tests/runtests.py
    a b  
    123123    get_apps()
    124124
    125125    # Load all the test model apps.
     126    test_labels_set = set([label.split('.')[0] for label in test_labels])
    126127    for model_dir, model_name in get_test_models():
    127128        model_label = '.'.join([model_dir, model_name])
    128         try:
    129             # if the model was named on the command line, or
    130             # no models were named (i.e., run all), import
    131             # this model and add it to the list to test.
    132             if not test_labels or model_name in set([label.split('.')[0] for label in test_labels]):
    133                 if verbosity >= 1:
    134                     print "Importing model %s" % model_name
    135                 mod = load_app(model_label)
    136                 if mod:
    137                     if model_label not in settings.INSTALLED_APPS:
    138                         settings.INSTALLED_APPS.append(model_label)
    139         except Exception, e:
    140             sys.stderr.write("Error while importing %s:" % model_name + ''.join(traceback.format_exception(*sys.exc_info())[1:]))
    141             continue
     129        # if the model was named on the command line, or
     130        # no models were named (i.e., run all), import
     131        # this model and add it to the list to test.
     132        if not test_labels or model_name in test_labels_set:
     133            if verbosity >= 1:
     134                print "Importing model %s" % model_name
     135            mod = load_app(model_label)
     136            if mod:
     137                if model_label not in settings.INSTALLED_APPS:
     138                    settings.INSTALLED_APPS.append(model_label)
    142139
    143140    # Add tests for invalid models.
    144141    extra_tests = []
Back to Top