Ticket #4460: runtests-granularity.patch

File runtests-granularity.patch, 2.1 KB (added by (removed), 17 years ago)
  • tests/runtests.py

    === modified file 'tests/runtests.py'
     
    103103
    104104    # Load all the test model apps.
    105105    test_models = []
     106    if not tests_to_run or '.*' in tests_to_run:
     107        desired_test = lambda x:True
     108    else:
     109        tests_filter = tests_to_run[:]
     110        for idx, x in enumerate(tests_filter):
     111            if x.endswith(".*"):
     112                x = x.rstrip(".*")
     113            tests_filter[idx] = x + "."
     114        def desired_test(name):
     115            name += '.'
     116            if name in tests_filter:
     117                return True
     118            return bool([x for x in tests_filter if name.startswith(x)])
     119
    106120    for model_dir, model_name in get_test_models():
    107121        model_label = '.'.join([model_dir, model_name])
    108122        try:
    109123            # if the model was named on the command line, or
    110124            # no models were named (i.e., run all), import
    111125            # this model and add it to the list to test.
    112             if not tests_to_run or model_name in tests_to_run:
     126            if desired_test(model_label):
    113127                if verbosity >= 1:
    114128                    print "Importing model %s" % model_name
    115129                mod = load_app(model_label)
     
    125139    extra_tests = []
    126140    for model_dir, model_name in get_invalid_models():
    127141        model_label = '.'.join([model_dir, model_name])
    128         if not tests_to_run or model_name in tests_to_run:
     142        if desired_test(model_label):
    129143            extra_tests.append(InvalidModelTestCase(model_label))
    130144
    131145    # Run the test suite, including the extra validation tests.
     
    144158
    145159if __name__ == "__main__":
    146160    from optparse import OptionParser
    147     usage = "%prog [options] [model model model ...]"
     161    usage = "%prog [options] [ [ modeltests.model1 modeltests.model2 ...] || modeltests.* ] [ [ regressiontests.regression1 regresiontests.regresion2 ...] || regresiontests.* ]"
    148162    parser = OptionParser(usage=usage)
    149163    parser.add_option('-v','--verbosity', action='store', dest='verbosity', default='0',
    150164        type='choice', choices=['0', '1', '2'],
Back to Top