Simplified SimpleTestCase.assertFormError()/assertFormsetErrors() calls in admin_views tests.

This commit is contained in:
Baptiste Mispelon 2022-02-14 11:34:23 +01:00 committed by Mariusz Felisiak
parent 1f749d6f12
commit 261885e4c1
1 changed files with 2 additions and 14 deletions

View File

@ -7816,12 +7816,7 @@ class AdminViewOnSiteTests(TestCase):
self.assertFormError(
response, "adminform", "some_required_info", ["This field is required."]
)
msg = (
"The form 'adminform' in context 0 does not contain the non-field error "
"'Error'"
)
with self.assertRaisesMessage(AssertionError, msg):
self.assertFormError(response, "adminform", None, ["Error"])
self.assertFormError(response, "adminform", None, [])
self.assertFormsetError(
response,
"inline_admin_formset",
@ -7832,14 +7827,7 @@ class AdminViewOnSiteTests(TestCase):
"contrived test case"
],
)
msg = (
"The formset 'inline_admin_formset' in context 22 does not contain any "
"non-form errors."
)
with self.assertRaisesMessage(AssertionError, msg):
self.assertFormsetError(
response, "inline_admin_formset", None, None, ["Error"]
)
self.assertFormsetError(response, "inline_admin_formset", None, None, [])
def test_change_view_form_and_formsets_run_validation(self):
"""