# Get the test case for the model case = test_models(model) # Create the test class name = "Test_%s" % model if new_available: cls = new.classobj(name, (unittest.TestCase,), {}) else: cls = types.new_class(name, (unittest.TestCase,)) cls = unittest.category(*case.level)(cls) driver[model] = cls globals()[name] = cls # # Iterate through all test scenarios and add test methods # for key, value in test_scenarios(lambda c: c.test_pickling): model, solver, io = key cls = driver[model] # Symbolic labels test_name = "test_"+solver+"_"+io +"_symbolic_labels" test_method = create_test_method(model, solver, io, value, True) if test_method is not None: setattr(cls, test_name, test_method) # Non-symbolic labels test_name = "test_"+solver+"_"+io +"_nonsymbolic_labels" test_method = create_test_method(model, solver, io, value, False) if test_method is not None: setattr(cls, test_name, test_method) # Reset the cls variable, since it contains a unittest.TestCase subclass. # This prevents this class from being processed twice!
case = test_models(model) if case().solve_should_fail: # Create the test class name = "Test_%s" % model if new_available: cls = new.classobj(name, (unittest.TestCase, ), {}) else: cls = types.new_class(name, (unittest.TestCase, )) cls = unittest.category(*case.level)(cls) driver[model] = cls globals()[name] = cls # # Iterate through all test scenarios and add test methods # for key, value in test_scenarios(): model, solver, io = key if model in driver: cls = driver[model] # TODO: expand these tests to cover ASL models once # a change in load_solutions behavior is # propagated into that framework. if "_kernel" in cls.__name__: test_name = "test_" + solver + "_" + io test_method = create_test_method(model, solver, io, value) if test_method is not None: setattr(cls, test_name, test_method) # Reset the cls variable, since it contains a unittest.TestCase subclass. # This prevents this class from being processed twice! cls = None
case = test_models(model) # Create the test class name = "Test_%s" % model if new_available: cls = new.classobj(name, (unittest.TestCase, ), {}) else: cls = types.new_class(name, (unittest.TestCase, )) cls.__module__ = __name__ cls = unittest.category(*case.level)(cls) driver[model] = cls globals()[name] = cls # # Iterate through all test scenarios and add test methods # for key, value in test_scenarios(lambda c: c.test_pickling): model, solver, io = key cls = driver[model] # Symbolic labels test_name = "test_" + solver + "_" + io + "_symbolic_labels" test_method = create_test_method(model, solver, io, value, True) if test_method is not None: test_method = unittest.category('smoke', 'nightly', solver)(test_method) setattr(cls, test_name, test_method) test_method = None # Non-symbolic labels test_name = "test_" + solver + "_" + io + "_nonsymbolic_labels" test_method = create_test_method(model, solver, io, value, False)
case = test_models(model) # Create the test class name = "Test_%s" % model if new_available: cls = new.classobj(name, (unittest.TestCase,), {}) else: cls = types.new_class(name, (unittest.TestCase,)) cls = unittest.category(*case.level)(cls) driver[model] = cls globals()[name] = cls # # Iterate through all test scenarios and add test methods # for key, value in test_scenarios(): model, solver, io = key cls = driver[model] # Symbolic labels test_name = "test_"+solver+"_"+io +"_symbolic_labels" test_method = create_test_method(model, solver, io, value, True) if test_method is not None: setattr(cls, test_name, test_method) # Non-symbolic labels test_name = "test_"+solver+"_"+io +"_nonsymbolic_labels" test_method = create_test_method(model, solver, io, value, False) if test_method is not None: setattr(cls, test_name, test_method)