diff options
| author | Ryan Kaskel <dev@ryankaskel.com> | 2013-05-20 12:13:03 -0400 |
|---|---|---|
| committer | Carl Meyer <carl@oddbird.net> | 2013-05-20 12:13:21 -0400 |
| commit | 4280217f31fc634d320b0cf30bcb6d582b19d784 (patch) | |
| tree | aa4635fcfef0eb7802a456d12791d987935eca0a /tests | |
| parent | 266c0bb23e9d64c47ace4d162e582febd5a1e336 (diff) | |
Fixed #20403 -- Ignore forms marked for deletion when validating max_num.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/forms_tests/tests/test_formsets.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/forms_tests/tests/test_formsets.py b/tests/forms_tests/tests/test_formsets.py index 31adb921ba..787f177677 100644 --- a/tests/forms_tests/tests/test_formsets.py +++ b/tests/forms_tests/tests/test_formsets.py @@ -986,6 +986,24 @@ class FormsFormsetTestCase(TestCase): self.assertEqual(list(formset.non_form_errors()), ['This is a non-form error']) + def test_validate_max_ignores_forms_marked_for_deletion(self): + class CheckForm(Form): + field = IntegerField() + + data = { + 'check-TOTAL_FORMS': '2', + 'check-INITIAL_FORMS': '0', + 'check-MAX_NUM_FORMS': '1', + 'check-0-field': '200', + 'check-0-DELETE': '', + 'check-1-field': '50', + 'check-1-DELETE': 'on', + } + CheckFormSet = formset_factory(CheckForm, max_num=1, validate_max=True, + can_delete=True) + formset = CheckFormSet(data, prefix='check') + self.assertTrue(formset.is_valid()) + data = { 'choices-TOTAL_FORMS': '1', # the number of forms rendered |
