Refs #20347 -- Added test for formset_factory()'s absolute_max default.

Co-authored-by: ethurgood <ethurgood@gmail.com>
This commit is contained in:
David Smith 2020-06-05 09:58:20 +02:00 committed by Mariusz Felisiak
parent 926148ef01
commit b5aa9cb20f
1 changed files with 15 additions and 0 deletions

View File

@ -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