mirror of
https://github.com/django/django.git
synced 2025-11-18 11:00:24 +00:00
updating the test error messaging
This commit is contained in:
parent
774a101280
commit
eebdb0719c
1 changed files with 2 additions and 17 deletions
|
|
@ -1714,26 +1714,11 @@ aria-describedby="id_birthday_error">
|
||||||
class FooForm(Form):
|
class FooForm(Form):
|
||||||
the_field = CharField(max_length=100)
|
the_field = CharField(max_length=100)
|
||||||
|
|
||||||
exc = ValidationError({"the_field": "This field has an error."})
|
exc = ValidationError({"the_field": "Something is wrong with the field."})
|
||||||
form = FooForm()
|
|
||||||
form.add_error("the_field", exc)
|
|
||||||
self.assertEqual(form.errors, {"the_field": ["This field has an error."]})
|
|
||||||
|
|
||||||
def test_add_error_validation_error_dict_multiple_fields(self):
|
|
||||||
class FooForm(Form):
|
|
||||||
the_field = CharField(max_length=100)
|
|
||||||
another_field = CharField(max_length=100)
|
|
||||||
|
|
||||||
exc = ValidationError(
|
|
||||||
{
|
|
||||||
"the_field": "Something is wrong with the field.",
|
|
||||||
"another_field": "Something is wrong with this other field.",
|
|
||||||
}
|
|
||||||
)
|
|
||||||
form = FooForm()
|
form = FooForm()
|
||||||
msg = (
|
msg = (
|
||||||
"The argument `field` must be `None` when the `error` argument "
|
"The argument `field` must be `None` when the `error` argument "
|
||||||
"contains errors for multiple fields."
|
"is a ValidationError with an error_dict."
|
||||||
)
|
)
|
||||||
with self.assertRaisesMessage(TypeError, msg):
|
with self.assertRaisesMessage(TypeError, msg):
|
||||||
form.add_error("the_field", exc)
|
form.add_error("the_field", exc)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue