#NEWLINE# def test_add_form_deletion_when_invalid( self ) : #NEWLINE# #INDENT# "\n        Make sure that an add form that is filled out, but marked for deletion\n        doesn't cause validation errors.\n        " #NEWLINE# PoemFormSet = inlineformset_factory ( Poet , Poem , can_delete = True , fields = '__all__' ) #NEWLINE# poet = Poet . objects . create ( name = 'test' ) #NEWLINE# data = { #NEWLINE# #INDENT# 'poem_set-TOTAL_FORMS' : '1' , #NEWLINE# 'poem_set-INITIAL_FORMS' : '0' , #NEWLINE# 'poem_set-MAX_NUM_FORMS' : '0' , #NEWLINE# 'poem_set-0-id' : '' , #NEWLINE# 'poem_set-0-poem' : '1' , #NEWLINE# 'poem_set-0-name' : ( 'x' * 1000 ) , #NEWLINE# #UNINDENT# } #NEWLINE# formset = PoemFormSet ( PoemFormSet , instance = poet ) #NEWLINE# self . assertEqual ( formset . is_valid ( ) , False ) #NEWLINE# self . assertEqual ( Poem . objects . count ( ) , 0 ) #NEWLINE# data [ 'poem_set-0-DELETE' ] = 'on' #NEWLINE# formset = PoemFormSet ( data , instance = poet ) #NEWLINE# self . assertEqual ( formset . is_valid ( ) , True ) #NEWLINE# formset . save ( ) #NEWLINE# self . assertEqual ( Poem . objects . count ( ) , 0 )