summaryrefslogtreecommitdiff
path: root/tests/composite_pk/tests.py
diff options
context:
space:
mode:
authorJaeHyuck Sa <wogur981208@gmail.com>2026-01-15 08:06:06 -0500
committerJacob Walls <jacobtylerwalls@gmail.com>2026-01-16 09:15:53 -0500
commitb98075dc6205374746cf1ad6d3533b9a1d9cf22e (patch)
tree2c227604a0fd4e8ac7572942592557b9323e7709 /tests/composite_pk/tests.py
parent07a16407452f5b62594661ae7ae589eca8cccd4d (diff)
Refs #36822 -- Hoisted bulk_batch_size() implementations to base backend.
Diffstat (limited to 'tests/composite_pk/tests.py')
-rw-r--r--tests/composite_pk/tests.py13
1 files changed, 5 insertions, 8 deletions
diff --git a/tests/composite_pk/tests.py b/tests/composite_pk/tests.py
index 3001847455..3653beceed 100644
--- a/tests/composite_pk/tests.py
+++ b/tests/composite_pk/tests.py
@@ -149,21 +149,18 @@ class CompositePKTests(TestCase):
def test_in_bulk_batching(self):
Comment.objects.all().delete()
- batching_required = connection.features.max_query_params is not None
- expected_queries = 2 if batching_required else 1
+ num_objects = 10
+ connection.features.__dict__.pop("max_query_params", None)
with unittest.mock.patch.object(
- type(connection.features), "max_query_params", 10
+ type(connection.features), "max_query_params", num_objects
):
- num_requiring_batching = (
- connection.ops.bulk_batch_size([Comment._meta.pk], []) + 1
- )
comments = [
Comment(id=i, tenant=self.tenant, user=self.user)
- for i in range(1, num_requiring_batching + 1)
+ for i in range(1, num_objects + 1)
]
Comment.objects.bulk_create(comments)
id_list = list(Comment.objects.values_list("pk", flat=True))
- with self.assertNumQueries(expected_queries):
+ with self.assertNumQueries(2):
comment_dict = Comment.objects.in_bulk(id_list=id_list)
self.assertQuerySetEqual(comment_dict, id_list)