Added another test to confirm fix in r16663.

This is the test case from #6045, which was fixed by the above commit.
Refs #6045, #16299

git-svn-id: http://code.djangoproject.com/svn/django/trunk@16679 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Malcolm Tredinnick 2011-08-24 03:51:33 +00:00
parent 75ddbf77a6
commit ec1226b83f
2 changed files with 18 additions and 1 deletions

View File

@ -19,3 +19,7 @@ class Issue(models.Model):
class Meta: class Meta:
ordering = ('num',) ordering = ('num',)
class UnicodeReferenceModel(models.Model):
others = models.ManyToManyField(u"UnicodeReferenceModel")

View File

@ -1,7 +1,7 @@
from django.db.models import Q from django.db.models import Q
from django.test import TestCase from django.test import TestCase
from models import Issue, User from models import Issue, User, UnicodeReferenceModel
class RelatedObjectTests(TestCase): class RelatedObjectTests(TestCase):
@ -73,3 +73,16 @@ class RelatedObjectTests(TestCase):
], ],
lambda i: i.num lambda i: i.num
) )
class RelatedObjectTests(TestCase):
def test_m2m_with_unicode_reference(self):
"""
Regression test for #6045: references to other models can be unicode
strings, providing they are directly convertible to ASCII.
"""
m1=UnicodeReferenceModel.objects.create()
m2=UnicodeReferenceModel.objects.create()
m2.others.add(m1) # used to cause an error (see ticket #6045)
m2.save()
list(m2.others.all()) # Force retrieval.