diff options
| author | saJaeHyukc <wogur981208@gmail.com> | 2025-03-09 00:42:16 +0900 |
|---|---|---|
| committer | Sarah Boyce <42296566+sarahboyce@users.noreply.github.com> | 2025-03-10 13:01:02 +0100 |
| commit | f480d5d3ed8234aea876f7eaf8a9154e5bf09d16 (patch) | |
| tree | 7452369196dcaf3b5d276bda08ece7e6addbff48 /tests/model_forms | |
| parent | 9120a19c4ecb643111b073dd1069e6b410a03c23 (diff) | |
Fixed #36201 -- Caught ValidationError in ModelChoiceField/ModelMultipleChoiceField.clean().
Signed-off-by: saJaeHyukc <wogur981208@gmail.com>
Diffstat (limited to 'tests/model_forms')
| -rw-r--r-- | tests/model_forms/test_uuid.py | 11 |
1 files changed, 10 insertions, 1 deletions
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") |
