mirror of
https://github.com/django/django.git
synced 2025-10-24 14:16:09 +00:00
Fixed #36201 -- Caught ValidationError in ModelChoiceField/ModelMultipleChoiceField.clean().
Signed-off-by: saJaeHyukc <wogur981208@gmail.com>
This commit is contained in:
@@ -30,6 +30,15 @@ class ModelFormBaseTest(TestCase):
|
||||
def test_model_multiple_choice_field_uuid_pk(self):
|
||||
f = forms.ModelMultipleChoiceField(UUIDPK.objects.all())
|
||||
with self.assertRaisesMessage(
|
||||
ValidationError, "“invalid_uuid” is not a valid UUID."
|
||||
ValidationError, "“invalid_uuid” is not a valid value."
|
||||
):
|
||||
f.clean(["invalid_uuid"])
|
||||
|
||||
def test_model_choice_invalid_pk_value_error_messages(self):
|
||||
f = forms.ModelChoiceField(UUIDPK.objects.all())
|
||||
with self.assertRaisesMessage(
|
||||
ValidationError,
|
||||
"['Select a valid choice. "
|
||||
"That choice is not one of the available choices.']",
|
||||
):
|
||||
f.clean("invalid")
|
||||
|
||||
Reference in New Issue
Block a user