From 0d2435328aaacdcfc5fae2baae21bfacf2244ee4 Mon Sep 17 00:00:00 2001 From: Adam Johnson Date: Fri, 10 Dec 2021 09:56:59 +0100 Subject: [PATCH] Added test for field names of ManagementForm. --- tests/forms_tests/tests/test_formsets.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/tests/forms_tests/tests/test_formsets.py b/tests/forms_tests/tests/test_formsets.py index 329b513f3a..1705d8bb6b 100644 --- a/tests/forms_tests/tests/test_formsets.py +++ b/tests/forms_tests/tests/test_formsets.py @@ -7,7 +7,10 @@ from django.forms import ( BaseForm, CharField, DateField, FileField, Form, IntegerField, SplitDateTimeField, formsets, ) -from django.forms.formsets import BaseFormSet, all_valid, formset_factory +from django.forms.formsets import ( + INITIAL_FORM_COUNT, MAX_NUM_FORM_COUNT, MIN_NUM_FORM_COUNT, + TOTAL_FORM_COUNT, BaseFormSet, ManagementForm, all_valid, formset_factory, +) from django.forms.utils import ErrorList from django.forms.widgets import HiddenInput from django.test import SimpleTestCase @@ -998,6 +1001,18 @@ class FormsFormsetTestCase(SimpleTestCase): """ ) + def test_management_form_field_names(self): + """The management form class has field names matching the constants.""" + self.assertCountEqual( + ManagementForm.base_fields, + [ + TOTAL_FORM_COUNT, + INITIAL_FORM_COUNT, + MIN_NUM_FORM_COUNT, + MAX_NUM_FORM_COUNT, + ], + ) + def test_management_form_prefix(self): """The management form has the correct prefix.""" formset = FavoriteDrinksFormSet()