summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMalcolm Tredinnick <malcolm.tredinnick@gmail.com>2011-08-24 03:51:33 +0000
committerMalcolm Tredinnick <malcolm.tredinnick@gmail.com>2011-08-24 03:51:33 +0000
commitec1226b83f226150671ee6f7844bcec04f600d75 (patch)
treeac9b3ac2b4f334bc17b6ad7716c1565a97f2382c /tests
parent75ddbf77a62b804740e887d940ded2f8c0bc1087 (diff)
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
Diffstat (limited to 'tests')
-rw-r--r--tests/modeltests/m2m_and_m2o/models.py4
-rw-r--r--tests/modeltests/m2m_and_m2o/tests.py15
2 files changed, 18 insertions, 1 deletions
diff --git a/tests/modeltests/m2m_and_m2o/models.py b/tests/modeltests/m2m_and_m2o/models.py
index 0fea1a2e7b..6072bd4c5e 100644
--- a/tests/modeltests/m2m_and_m2o/models.py
+++ b/tests/modeltests/m2m_and_m2o/models.py
@@ -19,3 +19,7 @@ class Issue(models.Model):
class Meta:
ordering = ('num',)
+
+class UnicodeReferenceModel(models.Model):
+ others = models.ManyToManyField(u"UnicodeReferenceModel")
+
diff --git a/tests/modeltests/m2m_and_m2o/tests.py b/tests/modeltests/m2m_and_m2o/tests.py
index dedf9cdf26..cb3dcc86bb 100644
--- a/tests/modeltests/m2m_and_m2o/tests.py
+++ b/tests/modeltests/m2m_and_m2o/tests.py
@@ -1,7 +1,7 @@
from django.db.models import Q
from django.test import TestCase
-from models import Issue, User
+from models import Issue, User, UnicodeReferenceModel
class RelatedObjectTests(TestCase):
@@ -73,3 +73,16 @@ class RelatedObjectTests(TestCase):
],
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.
+