Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed #11392 -- Enforced a predictable result order for a couple of t…

…est cases. Thanks to Nathan Auch for the report and patch.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@11119 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit e522e61a80aa9faae3fc0bcd69fd99d6b4951326 1 parent fe2747d
Russell Keith-Magee authored June 29, 2009
3  tests/modeltests/transactions/models.py
@@ -14,6 +14,9 @@ class Reporter(models.Model):
14 14
     last_name = models.CharField(max_length=30)
15 15
     email = models.EmailField()
16 16
 
  17
+    class Meta:
  18
+        ordering = ('first_name', 'last_name')
  19
+
17 20
     def __unicode__(self):
18 21
         return u"%s %s" % (self.first_name, self.last_name)
19 22
 
3  tests/regressiontests/null_fk/models.py
@@ -22,6 +22,9 @@ class Comment(models.Model):
22 22
     post = models.ForeignKey(Post, null=True)
23 23
     comment_text = models.CharField(max_length=250)
24 24
 
  25
+    class Meta:
  26
+        ordering = ('comment_text',)
  27
+
25 28
     def __unicode__(self):
26 29
         return self.comment_text
27 30
 
4  tests/regressiontests/serializers_regress/tests.py
@@ -103,7 +103,7 @@ def data_compare(testcase, pk, klass, data):
103 103
 def generic_compare(testcase, pk, klass, data):
104 104
     instance = klass.objects.get(id=pk)
105 105
     testcase.assertEqual(data[0], instance.data)
106  
-    testcase.assertEqual(data[1:], [t.data for t in instance.tags.all()])
  106
+    testcase.assertEqual(data[1:], [t.data for t in instance.tags.order_by('id')])
107 107
 
108 108
 def fk_compare(testcase, pk, klass, data):
109 109
     instance = klass.objects.get(id=pk)
@@ -111,7 +111,7 @@ def fk_compare(testcase, pk, klass, data):
111 111
 
112 112
 def m2m_compare(testcase, pk, klass, data):
113 113
     instance = klass.objects.get(id=pk)
114  
-    testcase.assertEqual(data, [obj.id for obj in instance.data.all()])
  114
+    testcase.assertEqual(data, [obj.id for obj in instance.data.order_by('id')])
115 115
 
116 116
 def im2m_compare(testcase, pk, klass, data):
117 117
     instance = klass.objects.get(id=pk)

0 notes on commit e522e61

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