[Django] #36883: Split up aggregation_regress.tests.AggregationTests.test_more_more, test_more_more_more

1 view
Skip to first unread message

Django

unread,
Jan 24, 2026, 7:56:10 PM (21 hours ago) Jan 24
to django-...@googlegroups.com
#36883: Split up aggregation_regress.tests.AggregationTests.test_more_more,
test_more_more_more
-------------------------------------+-------------------------------------
Reporter: Tim Graham | Type:
| Cleanup/optimization
Status: new | Component: Database
| layer (models, ORM)
Version: dev | Severity: Normal
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
These tests are extremely long and most queries are independent and test
different functionality. While working on the MongoDB backend, I found
that only parts of the test need to be skipped (e.g. `QuerySet.extra()`),
so I split up the test like this so the entire thing doesn't need to be
skipped. Use this patch as a starting point, but give the tests more
meaningful names.

{{{#!diff
diff --git a/tests/aggregation_regress/tests.py
b/tests/aggregation_regress/tests.py
index c7d9271dd8..e2169be69d 100644
--- a/tests/aggregation_regress/tests.py
+++ b/tests/aggregation_regress/tests.py
@@ -849,7 +848,7 @@ class AggregationTests(TestCase):
],
)

- def test_more_more(self):
+ def test_more_more1(self):
# Regression for #10113 - Fields mentioned in order_by() must be
# included in the GROUP BY. This only becomes a problem when the
# order_by introduces a new join.
@@ -869,6 +868,7 @@ class AggregationTests(TestCase):
lambda b: b.name,
)

+ def test_more_more2(self):
# Regression for #10127 - Empty select_related() works with
annotate
qs = (
Book.objects.filter(rating__lt=4.5)
@@ -897,6 +897,7 @@ class AggregationTests(TestCase):
lambda b: (b.name, b.authors__age__avg, b.publisher.name,
b.contact.name),
)

+ def test_more_more3(self):
# Regression for #10132 - If the values() clause only mentioned
extra
# (select=) columns, those columns are used for grouping
qs = (
@@ -931,6 +932,7 @@ class AggregationTests(TestCase):
],
)

+ def test_more_more4(self):
# Regression for #10182 - Queries with aggregate calls are
correctly
# realiased when used in a subquery
ids = (
@@ -947,6 +949,7 @@ class AggregationTests(TestCase):
lambda b: b.name,
)

+ def test_more_more5(self):
# Regression for #15709 - Ensure each group_by field only exists
once
# per query
qstr = str(
@@ -1046,7 +1049,7 @@ class AggregationTests(TestCase):
query,
)

- def test_more_more_more(self):
+ def test_more_more_more1(self):
# Regression for #10199 - Aggregate calls clone the original
query so
# the original query can still be used
books = Book.objects.all()
@@ -1065,6 +1068,7 @@ class AggregationTests(TestCase):
lambda b: b.name,
)

+ def test_more_more_more2(self):
# Regression for #10248 - Annotations work with dates()
qs = (
Book.objects.annotate(num_authors=Count("authors"))
@@ -1079,6 +1083,7 @@ class AggregationTests(TestCase):
],
)

+ def test_more_more_more3(self):
# Regression for #10290 - extra selects with parameters can be
used for
# grouping.
qs = (
@@ -1091,6 +1096,7 @@ class AggregationTests(TestCase):
qs, [150, 175, 224, 264, 473, 566], lambda b:
int(b["sheets"])
)

+ def test_more_more_more4(self):
# Regression for 10425 - annotations don't get in the way of a
count()
# clause
self.assertEqual(
@@ -1100,6 +1106,7 @@ class AggregationTests(TestCase):
Book.objects.annotate(Count("publisher")).values("publisher").count(), 6
)

+ def test_more_more_more5(self):
# Note: intentionally no order_by(), that case needs tests, too.
publishers = Publisher.objects.filter(id__in=[self.p1.id,
self.p2.id])
self.assertEqual(sorted(p.name for p in publishers), ["Apress",
"Sams"])
@@ -1123,6 +1130,7 @@ class AggregationTests(TestCase):
)
self.assertEqual(sorted(p.name for p in publishers), ["Apress",
"Sams"])

+ def test_more_more_more6(self):
# Regression for 10666 - inherited fields work with annotations
and
# aggregations
self.assertEqual(
@@ -1175,6 +1183,7 @@ class AggregationTests(TestCase):
],
)

+ def test_more_more_more7(self):
# Regression for #10766 - Shouldn't be able to reference an
aggregate
# fields in an aggregate() call.
msg = "Cannot compute Avg('mean_age'): 'mean_age' is an
aggregate"
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/36883>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Jan 24, 2026, 10:33:45 PM (18 hours ago) Jan 24
to django-...@googlegroups.com
#36883: Split up aggregation_regress.tests.AggregationTests.test_more_more,
test_more_more_more
-------------------------------------+-------------------------------------
Reporter: Tim Graham | Owner: (none)
Type: | Status: new
Cleanup/optimization |
Component: Database layer | Version: dev
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Clifford Gama):

* stage: Unreviewed => Accepted

--
Ticket URL: <https://code.djangoproject.com/ticket/36883#comment:1>

Django

unread,
Jan 24, 2026, 11:34:05 PM (17 hours ago) Jan 24
to django-...@googlegroups.com
#36883: Split up aggregation_regress.tests.AggregationTests.test_more_more,
test_more_more_more
-------------------------------------+-------------------------------------
Reporter: Tim Graham | Owner: Varun
Type: | Kasyap Pentamaraju
Cleanup/optimization | Status: assigned
Component: Database layer | Version: dev
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Varun Kasyap Pentamaraju):

* owner: (none) => Varun Kasyap Pentamaraju
* status: new => assigned

Comment:

Willing to contribute
--
Ticket URL: <https://code.djangoproject.com/ticket/36883#comment:2>

Django

unread,
1:05 AM (16 hours ago) 1:05 AM
to django-...@googlegroups.com
#36883: Split up aggregation_regress.tests.AggregationTests.test_more_more,
test_more_more_more
-------------------------------------+-------------------------------------
Reporter: Tim Graham | Owner: Varun
Type: | Kasyap Pentamaraju
Cleanup/optimization | Status: assigned
Component: Database layer | Version: dev
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Varun Kasyap Pentamaraju):

* has_patch: 0 => 1

Comment:

https://github.com/django/django/pull/20584
--
Ticket URL: <https://code.djangoproject.com/ticket/36883#comment:3>
Reply all
Reply to author
Forward
0 new messages