mirror of
https://github.com/django/django.git
synced 2024-11-29 22:56:46 +01:00
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.
This commit is contained in:
parent
cd79f33723
commit
33dd8f5442
@ -581,6 +581,7 @@ class AggregationTests(TestCase):
|
|||||||
6
|
6
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Note: intentionally no order_by(), that case needs tests, too.
|
||||||
publishers = Publisher.objects.filter(id__in=[1, 2])
|
publishers = Publisher.objects.filter(id__in=[1, 2])
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
sorted(p.name for p in publishers),
|
sorted(p.name for p in publishers),
|
||||||
@ -591,10 +592,15 @@ class AggregationTests(TestCase):
|
|||||||
)
|
)
|
||||||
|
|
||||||
publishers = publishers.annotate(n_books=Count("book"))
|
publishers = publishers.annotate(n_books=Count("book"))
|
||||||
|
sorted_publishers = sorted(publishers, key=lambda x: x.name)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
publishers[0].n_books,
|
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),
|
||||||
|
Loading…
Reference in New Issue
Block a user