summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorAnssi Kääriäinen <akaariai@gmail.com>2013-08-20 11:33:44 +0300
committerAnssi Kääriäinen <akaariai@gmail.com>2013-08-20 11:33:44 +0300
commit8dc76c4b9108f49afc5db07a23f34ad259a7642b (patch)
treed2bbfb4b7019c834e1de309350d4c7d50ff3c51b /tests
parent905409855c6b69f613190fcc2d8bd8bf5e1580b5 (diff)
Fixed test failure caused by different NULL ordering between backends
Diffstat (limited to 'tests')
-rw-r--r--tests/queries/models.py4
-rw-r--r--tests/queries/tests.py8
2 files changed, 10 insertions, 2 deletions
diff --git a/tests/queries/models.py b/tests/queries/models.py
index 71346d8be9..3a638b2867 100644
--- a/tests/queries/models.py
+++ b/tests/queries/models.py
@@ -262,9 +262,13 @@ class ReservedName(models.Model):
return self.name
# A simpler shared-foreign-key setup that can expose some problems.
+@python_2_unicode_compatible
class SharedConnection(models.Model):
data = models.CharField(max_length=10)
+ def __str__(self):
+ return self.data
+
class PointerA(models.Model):
connection = models.ForeignKey(SharedConnection)
diff --git a/tests/queries/tests.py b/tests/queries/tests.py
index bb4e9eee8f..91d4b17d0b 100644
--- a/tests/queries/tests.py
+++ b/tests/queries/tests.py
@@ -2984,7 +2984,11 @@ class Ticket14056Tests(TestCase):
s2 = SharedConnection.objects.create(data='s2')
s3 = SharedConnection.objects.create(data='s3')
PointerA.objects.create(connection=s2)
+ expected_ordering = (
+ [s1, s3, s2] if connection.features.nulls_order_largest
+ else [s2, s1, s3]
+ )
self.assertQuerysetEqual(
- SharedConnection.objects.order_by('pointera__connection', 'pk'),
- [s1, s3, s2], lambda x: x
+ SharedConnection.objects.order_by('-pointera__connection', 'pk'),
+ expected_ordering, lambda x: x
)