1
0
mirror of https://github.com/django/django.git synced 2025-10-23 21:59:11 +00:00

Fixed #14567 -- Made ModelMultipleChoiceField return EmptyQuerySet as empty value

This commit is contained in:
Stephen Burrows
2012-10-03 19:50:12 +03:00
committed by Anssi Kääriäinen
parent d25a599dca
commit 218abcc9e5
6 changed files with 40 additions and 7 deletions

View File

@@ -8,6 +8,7 @@ from django import forms
from django.core.files.uploadedfile import SimpleUploadedFile
from django.core.validators import ValidationError
from django.db import connection
from django.db.models.query import EmptyQuerySet
from django.forms.models import model_to_dict
from django.utils.unittest import skipUnless
from django.test import TestCase
@@ -1035,8 +1036,8 @@ class OldFormForXTests(TestCase):
f.clean([c6.id])
f = forms.ModelMultipleChoiceField(Category.objects.all(), required=False)
self.assertEqual(f.clean([]), [])
self.assertEqual(f.clean(()), [])
self.assertIsInstance(f.clean([]), EmptyQuerySet)
self.assertIsInstance(f.clean(()), EmptyQuerySet)
with self.assertRaises(ValidationError):
f.clean(['10'])
with self.assertRaises(ValidationError):