From 33dd8f544205be923e2a06106909ebcd3583526b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anssi=20K=C3=A4=C3=A4ri=C3=A4inen?= Date: Tue, 28 May 2013 08:53:52 +0300 Subject: [PATCH] Fixed random aggregation_regress test_more_more_more() failure The cause was assuming that an unordered queryset returns the values always in the same order. --- tests/aggregation_regress/tests.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tests/aggregation_regress/tests.py b/tests/aggregation_regress/tests.py index 6c5a43664a..80441b9a60 100644 --- a/tests/aggregation_regress/tests.py +++ b/tests/aggregation_regress/tests.py @@ -581,6 +581,7 @@ class AggregationTests(TestCase): 6 ) + # Note: intentionally no order_by(), that case needs tests, too. publishers = Publisher.objects.filter(id__in=[1, 2]) self.assertEqual( sorted(p.name for p in publishers), @@ -591,10 +592,15 @@ class AggregationTests(TestCase): ) publishers = publishers.annotate(n_books=Count("book")) + sorted_publishers = sorted(publishers, key=lambda x: x.name) self.assertEqual( - publishers[0].n_books, + sorted_publishers[0].n_books, 2 ) + self.assertEqual( + sorted_publishers[1].n_books, + 1 + ) self.assertEqual( sorted(p.name for p in publishers),