From e522e61a80aa9faae3fc0bcd69fd99d6b4951326 Mon Sep 17 00:00:00 2001 From: Russell Keith-Magee Date: Mon, 29 Jun 2009 12:29:48 +0000 Subject: [PATCH] Fixed #11392 -- Enforced a predictable result order for a couple of test 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 --- tests/modeltests/transactions/models.py | 3 +++ tests/regressiontests/null_fk/models.py | 3 +++ tests/regressiontests/serializers_regress/tests.py | 4 ++-- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/tests/modeltests/transactions/models.py b/tests/modeltests/transactions/models.py index 06d21bbdd4..6763144ca5 100644 --- a/tests/modeltests/transactions/models.py +++ b/tests/modeltests/transactions/models.py @@ -14,6 +14,9 @@ class Reporter(models.Model): last_name = models.CharField(max_length=30) email = models.EmailField() + class Meta: + ordering = ('first_name', 'last_name') + def __unicode__(self): return u"%s %s" % (self.first_name, self.last_name) diff --git a/tests/regressiontests/null_fk/models.py b/tests/regressiontests/null_fk/models.py index 529dde5039..49887819ac 100644 --- a/tests/regressiontests/null_fk/models.py +++ b/tests/regressiontests/null_fk/models.py @@ -22,6 +22,9 @@ class Comment(models.Model): post = models.ForeignKey(Post, null=True) comment_text = models.CharField(max_length=250) + class Meta: + ordering = ('comment_text',) + def __unicode__(self): return self.comment_text diff --git a/tests/regressiontests/serializers_regress/tests.py b/tests/regressiontests/serializers_regress/tests.py index 4e52d81811..de7ddcc9f7 100644 --- a/tests/regressiontests/serializers_regress/tests.py +++ b/tests/regressiontests/serializers_regress/tests.py @@ -103,7 +103,7 @@ def data_compare(testcase, pk, klass, data): def generic_compare(testcase, pk, klass, data): instance = klass.objects.get(id=pk) testcase.assertEqual(data[0], instance.data) - testcase.assertEqual(data[1:], [t.data for t in instance.tags.all()]) + testcase.assertEqual(data[1:], [t.data for t in instance.tags.order_by('id')]) def fk_compare(testcase, pk, klass, data): instance = klass.objects.get(id=pk) @@ -111,7 +111,7 @@ def fk_compare(testcase, pk, klass, data): def m2m_compare(testcase, pk, klass, data): instance = klass.objects.get(id=pk) - testcase.assertEqual(data, [obj.id for obj in instance.data.all()]) + testcase.assertEqual(data, [obj.id for obj in instance.data.order_by('id')]) def im2m_compare(testcase, pk, klass, data): instance = klass.objects.get(id=pk)