What is the django way to check for non-field validation errors?
For example, an email field will verify that the entered text is a valid email address, but not a field error will be displayed above the form, without regard to any field. For example, he would say that this email address is already registered.
When testing applications, how do you test these off-field validation errors?
Edit: To make the question more clear. I have a custom validation function, but I would like to verify that it throws errors that it should use using the unittest frame provided by Django.
I could call the function directly and test it this way, but this does not guarantee that it is used correctly in the view (i.e. I want to do an integration test).
Thanks.
Edit: I found a solution on how to check , not check a field error.
Running with assertFormError. Change the field name to None and change the error line to a list of error lines.
self.assertFormError(response, 'form', 'field name', 'error') # Test single field error self.assertFormError(response, 'form', None, ['Error #1.', 'Error #2']) # Test general form errors
source share