diff options
| author | David Smith <smithdc@gmail.com> | 2020-06-05 09:58:20 +0200 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2020-06-05 10:00:25 +0200 |
| commit | b5aa9cb20f2d8fbffec3bc18aa31fca5f26d6f64 (patch) | |
| tree | 4ceffdb0ee07c052df20720ad7b4fd3a9f4c8164 /tests/forms_tests | |
| parent | 926148ef019abcac3a9988c78734d9336d69f24e (diff) | |
Refs #20347 -- Added test for formset_factory()'s absolute_max default.
Co-authored-by: ethurgood <ethurgood@gmail.com>
Diffstat (limited to 'tests/forms_tests')
| -rw-r--r-- | tests/forms_tests/tests/test_formsets.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/tests/forms_tests/tests/test_formsets.py b/tests/forms_tests/tests/test_formsets.py index 689f972a07..117b50fa7c 100644 --- a/tests/forms_tests/tests/test_formsets.py +++ b/tests/forms_tests/tests/test_formsets.py @@ -877,6 +877,21 @@ class FormsFormsetTestCase(SimpleTestCase): <td><input id="id_form-2-name" name="form-2-name" type="text" value="Jack and Coke"></td></tr>""" ) + def test_default_absolute_max(self): + # absolute_max defaults to 2 * DEFAULT_MAX_NUM if max_num is None. + data = { + 'form-TOTAL_FORMS': 2001, + 'form-INITIAL_FORMS': '0', + 'form-MAX_NUM_FORMS': '0', + } + formset = FavoriteDrinksFormSet(data=data) + self.assertIs(formset.is_valid(), False) + self.assertEqual( + formset.non_form_errors(), + ['Please submit 1000 or fewer forms.'], + ) + self.assertEqual(formset.absolute_max, 2000) + def test_more_initial_form_result_in_one(self): """ One form from initial and extra=3 with max_num=2 results in the one |
