Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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
  • Loading branch information...
commit ec1226b83f226150671ee6f7844bcec04f600d75 1 parent 75ddbf7
Malcolm Tredinnick authored August 24, 2011
4  tests/modeltests/m2m_and_m2o/models.py
@@ -19,3 +19,7 @@ def __unicode__(self):
19 19
 
20 20
     class Meta:
21 21
         ordering = ('num',)
  22
+
  23
+class UnicodeReferenceModel(models.Model): 
  24
+    others = models.ManyToManyField(u"UnicodeReferenceModel") 
  25
+
15  tests/modeltests/m2m_and_m2o/tests.py
... ...
@@ -1,7 +1,7 @@
1 1
 from django.db.models import Q
2 2
 from django.test import TestCase
3 3
 
4  
-from models import Issue, User
  4
+from models import Issue, User, UnicodeReferenceModel
5 5
 
6 6
 
7 7
 class RelatedObjectTests(TestCase):
@@ -73,3 +73,16 @@ def test_m2m_and_m2o(self):
73 73
             ],
74 74
             lambda i: i.num
75 75
         )
  76
+
  77
+class RelatedObjectTests(TestCase): 
  78
+    def test_m2m_with_unicode_reference(self): 
  79
+        """
  80
+        Regression test for #6045: references to other models can be unicode
  81
+        strings, providing they are directly convertible to ASCII.
  82
+        """
  83
+        m1=UnicodeReferenceModel.objects.create() 
  84
+        m2=UnicodeReferenceModel.objects.create() 
  85
+        m2.others.add(m1) # used to cause an error (see ticket #6045) 
  86
+        m2.save() 
  87
+        list(m2.others.all()) # Force retrieval.
  88
+

0 notes on commit ec1226b

Please sign in to comment.
Something went wrong with that request. Please try again.