From f480d5d3ed8234aea876f7eaf8a9154e5bf09d16 Mon Sep 17 00:00:00 2001 From: saJaeHyukc Date: Sun, 9 Mar 2025 00:42:16 +0900 Subject: Fixed #36201 -- Caught ValidationError in ModelChoiceField/ModelMultipleChoiceField.clean(). Signed-off-by: saJaeHyukc --- tests/model_forms/test_uuid.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'tests/model_forms') diff --git a/tests/model_forms/test_uuid.py b/tests/model_forms/test_uuid.py index 583b3fea94..b60ec93086 100644 --- a/tests/model_forms/test_uuid.py +++ b/tests/model_forms/test_uuid.py @@ -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") -- cgit v1.3