

def test_basic_formset(self):
    formset = ChoiceFormSet(auto_id=False, prefix='choices')
    self.assertEqual(str(formset), '<input type="hidden" name="choices-TOTAL_FORMS" value="1" /><input type="hidden" name="choices-INITIAL_FORMS" value="0" /><input type="hidden" name="choices-MAX_NUM_FORMS" />\n<tr><th>Choice:</th><td><input type="text" name="choices-0-choice" /></td></tr>\n<tr><th>Votes:</th><td><input type="text" name="choices-0-votes" /></td></tr>')
    data = {
        'choices-TOTAL_FORMS': '1',
        'choices-INITIAL_FORMS': '0',
        'choices-MAX_NUM_FORMS': '0',
        'choices-0-choice': 'Calexico',
        'choices-0-votes': '100',
    }
    formset = ChoiceFormSet(data, auto_id=False, prefix='choices')
    self.assertTrue(formset.is_valid())
    self.assertEqual([form.cleaned_data for form in formset.forms], [{
        'votes': 100,
        'choice': 'Calexico',
    }])
    formset = ChoiceFormSet()
    self.assertFalse(formset.is_valid())

dataset/ETHPy150Open AppScale/appscale/AppServer/lib/django-1.2/tests/regressiontests/forms/tests/formsets.py FormsFormsetTestCase.test_basic_formset/original