'Test that a custom formfield_callback is used if provided'

def test_custom_callback(self):

    callback_args = []
    def callback(db_field, **kwargs):
        callback_args.append((db_field, kwargs))
        return db_field.formfield(**kwargs)
    widget = forms.Textarea()
    class BaseForm(forms.ModelForm, ):
        class Meta:
            model = Person
            widgets = {u'name': widget}
            fields = u'__all__'
    _ = modelform_factory(Person, form=BaseForm, formfield_callback=callback)
    (id_field, name_field) = Person._meta.fields
    self.assertEqual(callback_args, [(id_field, {}), (name_field, {u'widget': widget})])
