'Helper to call formfield_for_dbfield for a given model and field name
and verify that the returned formfield is appropriate.'

def assertFormfield(self, model, fieldname, widgetclass, **admin_overrides):

    class MyModelAdmin(admin.ModelAdmin, ):
        pass
    for k in admin_overrides:
        setattr(MyModelAdmin, k, admin_overrides[k])
    ma = MyModelAdmin(model, admin.site)
    ff = ma.formfield_for_dbfield(model._meta.get_field(fieldname), request=None)
    if isinstance(ff.widget, widgets.RelatedFieldWidgetWrapper):
        widget = ff.widget.widget
    else:
        widget = ff.widget
    self.assertIsInstance(widget, widgetclass)
    return ff
