def __call__(self, cls):
if self.preferences is not None:
for field_name, pref_factory in self.preferences:
template_methods = inspect.getmembers(self.__class__, inspect.isfunction)
for name, tempalte_method in template_methods:
if name.startswith('template_'):
test_method_name_template, test_method = tempalte_method(field_name, pref_factory)
test_method_name = test_method_name_template % {'field_name': field_name}
if not hasattr(cls, test_method_name):
setattr(cls, test_method_name, test_method)
return cls