Opened 19 months ago
Last modified 19 months ago
#34484 closed Bug
HttpRequest.__deepcopy__ doesn't deepcopy attributes — at Initial Version
Reported by: | Adam Johnson | Owned by: | nobody |
---|---|---|---|
Component: | HTTP handling | Version: | 4.2 |
Severity: | Release blocker | Keywords: | |
Cc: | Triage Stage: | Accepted | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
Regression in Django 4.2. Deepcopying a HttpRequest no longer deepcopies its attributes, including attached ones like session
.
Leads to test pollution where a request is created in setUpTestData, for example:
from django.test import TestCase from django.test import RequestFactory class ExampleTests(TestCase): @classmethod def setUpTestData(cls): cls.request = RequestFactory().get("/") cls.request.session = {} def test_adding(self): self.request.session["foo"] = 1 self.assertEqual(self.request.session, {"foo": 1}) def test_looking(self): self.assertEqual(self.request.session, {})
(Simplified from a real test suite.)
Bisected to #29186 / 6220c445c40a6a7f4d442de8bde2628346153963, using these commands to run the above test case:
git bisect start facc153af7 ff8e5eacda git bisect run sh -c 'cd tests && ./runtests.py test_regression -v 2'
I see #34482 was also just opened as a regression from that same ticket.
Note:
See TracTickets
for help on using tickets.