def data_decorator(cls):
def generate_test_func(name, original_function, num, params):<EOL><INDENT>if original_function._provider_name_suffix:<EOL><INDENT>data_name = params[<NUM_LIT:0>]<EOL>params = params[<NUM_LIT:1>:]<EOL><DEDENT>else:<EOL><INDENT>data_name = num<EOL><DEDENT>expanded_name = '<STR_LIT>' % (name, data_name)<EOL>def generated_test_function(self):<EOL><INDENT>original_function(self, *params)<EOL><DEDENT>setattr(cls, expanded_name, generated_test_function)<EOL><DEDENT>for name in dir(cls):<EOL><INDENT>func = getattr(cls, name)<EOL>if hasattr(func, '<STR_LIT>'):<EOL><INDENT>num = <NUM_LIT:1><EOL>for params in getattr(cls, func._provider_method)():<EOL><INDENT>generate_test_func(name, func, num, params)<EOL>num += <NUM_LIT:1><EOL><DEDENT><DEDENT><DEDENT>return cls<EOL>
A class decorator that works with the @provider decorator to generate test
method from a data provider