'Make sure that an add form that is filled out, but marked for deletion
doesn\'t cause validation errors.'

def test_add_form_deletion_when_invalid(self):

    PoetFormSet = modelformset_factory(Poet, fields='__all__', can_delete=True)
    poet = Poet.objects.create(name='test')
    data = {'form-TOTAL_FORMS': '3', 'form-INITIAL_FORMS': '1', 'form-MAX_NUM_FORMS': '0', 'form-0-id': str(poet.id), 'form-0-name': 'test', 'form-1-id': '', 'form-1-name': ('x' * 1000), 'form-2-id': str(poet.id), 'form-2-name': 'test2'}
    formset = PoetFormSet(data, queryset=Poet.objects.all())
    self.assertIs(formset.is_valid(), False)
    self.assertEqual(Poet.objects.count(), 1)
    data['form-0-DELETE'] = 'on'
    data['form-1-DELETE'] = 'on'
    data['form-2-DELETE'] = 'on'
    formset = PoetFormSet(data, queryset=Poet.objects.all())
    self.assertIs(formset.is_valid(), True)
    formset.save()
    self.assertEqual(Poet.objects.count(), 0)
