From 2f9861d823620da7ecb291a8f005f53da12b1e89 Mon Sep 17 00:00:00 2001 From: Tim Graham Date: Mon, 31 Oct 2016 15:21:05 -0400 Subject: Fixed #27148 -- Fixed ModelMultipleChoiceField crash with invalid UUID. --- tests/model_forms/test_uuid.py | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'tests/model_forms') diff --git a/tests/model_forms/test_uuid.py b/tests/model_forms/test_uuid.py index 4dc7d511d7..b30da6d465 100644 --- a/tests/model_forms/test_uuid.py +++ b/tests/model_forms/test_uuid.py @@ -1,6 +1,7 @@ from __future__ import unicode_literals from django import forms +from django.core.exceptions import ValidationError from django.test import TestCase from .models import UUIDPK @@ -27,3 +28,8 @@ class ModelFormBaseTest(TestCase): msg = "The UUIDPK could not be changed because the data didn't validate." with self.assertRaisesMessage(ValueError, msg): form.save() + + 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."): + f.clean(['invalid_uuid']) -- cgit v1.3