Permalink
Browse files

[1.4.x] 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.

Backport of 33dd8f5
  • Loading branch information...
1 parent f2a9f71 commit 83420e70ef98c015207f8a49bd35ebb098ac6df5 @timgraham timgraham committed Apr 19, 2014
Showing with 3 additions and 4 deletions.
  1. +3 −4 tests/regressiontests/aggregation_regress/tests.py
View
7 tests/regressiontests/aggregation_regress/tests.py
@@ -587,10 +587,9 @@ def test_more_more_more(self):
)
publishers = publishers.annotate(n_books=Count("book"))
- self.assertEqual(
- publishers[0].n_books,
- 2
- )
+ sorted_publishers = sorted(publishers, key=lambda x: x.name)
+ self.assertEqual(sorted_publishers[0].n_books, 2)
+ self.assertEqual(sorted_publishers[1].n_books, 1)
self.assertEqual(
sorted(p.name for p in publishers),

0 comments on commit 83420e7

Please sign in to comment.