Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

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.
  • Loading branch information...
commit 33dd8f544205be923e2a06106909ebcd3583526b 1 parent cd79f33
@akaariai akaariai authored
Showing with 7 additions and 1 deletion.
  1. +7 −1 tests/aggregation_regress/tests.py
View
8 tests/aggregation_regress/tests.py
@@ -581,6 +581,7 @@ def test_more_more_more(self):
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 @@ def test_more_more_more(self):
)
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),
Please sign in to comment.
Something went wrong with that request. Please try again.