Changeset 1a6cd57 in sasmodels for sasmodels/model_test.py


Ignore:
Timestamp:
Oct 11, 2016 11:25:56 AM (8 years ago)
Author:
jhbakker
Branches:
master, core_shell_microgels, costrafo411, magnetic_model, ticket-1257-vesicle-product, ticket_1156, ticket_1265_superball, ticket_822_more_unit_tests
Children:
2ccb775, 997d4eb
Parents:
c1904f6
Message:

commit of stuff from master from fast-merge

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sasmodels/model_test.py

    r897ca7f r1a6cd57  
    121121 
    122122            # test using dll if desired 
    123             if 'dll' in loaders: 
     123            if 'dll' in loaders or not core.HAVE_OPENCL: 
    124124                test_name = "Model: %s, Kernel: dll"%model_name 
    125125                test_method_name = "test_%s_dll" % model_info.id 
     
    270270 
    271271    # Build a test suite containing just the model 
    272     loaders = ['opencl'] 
     272    loaders = ['opencl'] if core.HAVE_OPENCL else ['dll'] 
    273273    models = [model] 
    274274    try: 
     
    288288        stream.writeln(tb) 
    289289 
    290     # Check if there are user defined tests. 
    291     # Yes, it is naughty to peek into the structure of the test suite, and 
    292     # to assume that it contains only one test. 
    293     if not suite._tests[0].info.tests: 
    294         stream.writeln("Note: %s has no user defined tests."%model) 
     290    # Warn if there are no user defined tests. 
     291    # Note: the test suite constructed above only has one test in it, which 
     292    # runs through some smoke tests to make sure the model runs, then runs 
     293    # through the input-output pairs given in the model definition file.  To 
     294    # check if any such pairs are defined, therefore, we just need to check if 
     295    # they are in the first test of the test suite.  We do this with an 
     296    # iterator since we don't have direct access to the list of tests in the 
     297    # test suite. 
     298    for test in suite: 
     299        if not test.info.tests: 
     300            stream.writeln("Note: %s has no user defined tests."%model) 
     301        break 
     302    else: 
     303        stream.writeln("Note: no test suite created --- this should never happen") 
    295304 
    296305 
     
    325334        models = models[1:] 
    326335    elif models and models[0] == 'opencl_and_dll': 
    327         loaders = ['opencl', 'dll'] 
     336        loaders = ['opencl', 'dll'] if core.HAVE_OPENCL else ['dll'] 
    328337        models = models[1:] 
    329338    else: 
    330         loaders = ['opencl', 'dll'] 
     339        loaders = ['opencl', 'dll'] if core.HAVE_OPENCL else ['dll'] 
    331340    if not models: 
    332341        print("""\ 
     
    357366    Run "nosetests sasmodels" on the command line to invoke it. 
    358367    """ 
    359     tests = make_suite(['opencl', 'dll'], ['all']) 
     368    loaders = ['opencl', 'dll'] if core.HAVE_OPENCL else ['dll'] 
     369    tests = make_suite(loaders, ['all']) 
    360370    for test_i in tests: 
    361         yield test_i.run_all 
     371        # In order for nosetest to see the correct test name, need to set 
     372        # the description attribute of the returned function.  Since we 
     373        # can't do this for the returned instance, wrap it in a lambda and 
     374        # set the description on the lambda.  Otherwise we could just do: 
     375        #    yield test_i.run_all 
     376        L = lambda: test_i.run_all() 
     377        L.description = test_i.test_name 
     378        yield L 
    362379 
    363380 
Note: See TracChangeset for help on using the changeset viewer.