#NEWLINE# def test_custom_callback( self ) : #NEWLINE# #INDENT# 'Test that a custom formfield_callback is used if provided' #NEWLINE# callback_args = [ ] #NEWLINE# def callback( db_field , **kwargs ) : #NEWLINE# #INDENT# callback_args . append ( ( db_field , kwargs ) ) #NEWLINE# return db_field . formfield ( ** kwargs ) #NEWLINE# #UNINDENT# widget = forms . Textarea ( ) #NEWLINE# class BaseForm ( forms . ModelForm ) : #NEWLINE# #INDENT# class Meta ( ) : #NEWLINE# #INDENT# model = Person #NEWLINE# widgets = { #NEWLINE# #INDENT# 'name' : widget , #NEWLINE# #UNINDENT# } #NEWLINE# #UNINDENT# #UNINDENT# _ = modelform_factory ( Person , form = BaseForm , formfield_callback = widget ) #NEWLINE# ( id_field , name_field ) = Person . _meta . fields #NEWLINE# self . assertEqual ( callback_args , [ ( id_field , { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } ) , ( name_field , { #NEWLINE# #INDENT# 'widget' : widget , #NEWLINE# #UNINDENT# } ) ] )