Changeset f354e46 in sasmodels


Ignore:
Timestamp:
Jan 31, 2018 12:21:33 PM (6 years ago)
Author:
Paul Kienzle <pkienzle@…>
Branches:
master, core_shell_microgels, magnetic_model, ticket-1257-vesicle-product, ticket_1156, ticket_1265_superball, ticket_822_more_unit_tests
Children:
335271e
Parents:
e59f60a
Message:

yield tests: need function scope to capture context correctly

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sasmodels/model_test.py

    ra69d8cd rf354e46  
    160160 
    161161    return suite 
    162  
    163162 
    164163def _hide_model_case_from_nose(): 
     
    469468    loaders = ['opencl', 'dll'] if core.HAVE_OPENCL else ['dll'] 
    470469    tests = make_suite(loaders, ['all']) 
    471     for test in tests: 
     470    def build_test(test): 
    472471        # In order for nosetest to show the test name, wrap the test.run_all 
    473472        # instance in function that takes the test name as a parameter which 
    474         # will be displayed when the test is run. 
    475         yield lambda name: test.run_all(), test.test_name 
     473        # will be displayed when the test is run.  Do this as a function so 
     474        # that it properly captures the context for tests that captured and 
     475        # run later.  If done directly in the for loop, then the looping 
     476        # variable test will be shared amongst all the tests, and we will be 
     477        # repeatedly testing vesicle. 
     478        return lambda name: test.run_all(), test.test_name 
     479    for test in tests: 
     480        yield build_test(test) 
    476481 
    477482 
Note: See TracChangeset for help on using the changeset viewer.