MCPcopy
hub / github.com/django/django / assertFormError

Method assertFormError

django/test/testcases.py:698–711  ·  view source on GitHub ↗

Assert that a field named "field" on the given form object has specific errors. errors can be either a single error message or a list of errors messages. Using errors=[] test that the field has no errors. You can pass field=None to check the form's non-fiel

(self, form, field, errors, msg_prefix="")

Source from the content-addressed store, hash-verified

696 self.assertEqual(field_errors, errors, msg_prefix + failure_message)
697
698 def assertFormError(self, form, field, errors, msg_prefix=""):
699 """
700 Assert that a field named "field" on the given form object has specific
701 errors.
702
703 errors can be either a single error message or a list of errors
704 messages. Using errors=[] test that the field has no errors.
705
706 You can pass field=None to check the form's non-field errors.
707 """
708 if msg_prefix:
709 msg_prefix += ": "
710 errors = to_list(errors)
711 self._assert_form_error(form, field, errors, msg_prefix)
712
713 def assertFormSetError(self, formset, form_index, field, errors, msg_prefix=""):
714 """

Callers

nothing calls this directly

Calls 2

_assert_form_errorMethod · 0.95
to_listFunction · 0.85

Tested by

no test coverage detected