Refs -- Added test for formset_factory()'s absolute_max default.
@@ -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
