[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 33dd8f5442
This commit is contained in:
Tim Graham 2014-04-19 13:01:52 -04:00
parent f2a9f71565
commit 83420e70ef
1 changed files with 3 additions and 4 deletions

View File

@ -587,10 +587,9 @@ class AggregationTests(TestCase):
) )
publishers = publishers.annotate(n_books=Count("book")) publishers = publishers.annotate(n_books=Count("book"))
self.assertEqual( sorted_publishers = sorted(publishers, key=lambda x: x.name)
publishers[0].n_books, self.assertEqual(sorted_publishers[0].n_books, 2)
2 self.assertEqual(sorted_publishers[1].n_books, 1)
)
self.assertEqual( self.assertEqual(
sorted(p.name for p in publishers), sorted(p.name for p in publishers),