summaryrefslogtreecommitdiff
path: root/tests/requests_tests
diff options
context:
space:
mode:
authorMariusz Felisiak <felisiak.mariusz@gmail.com>2023-04-12 09:25:45 +0200
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2023-04-12 18:52:43 +0200
commit280ca147af9cdfce1ca9cb14cc3c5527ff6c7a02 (patch)
tree2eabfca62fb35d84343ec7317dd7ea10b396bda1 /tests/requests_tests
parentdfc720c521062cdefd64bc48a11838b0fa583439 (diff)
downloaddjango-280ca147af9cdfce1ca9cb14cc3c5527ff6c7a02.tar.gz
Fixed #34484, Refs #34482 -- Reverted "Fixed #29186 -- Fixed pickling HttpRequest and subclasses."
This reverts commit 6220c445c40a6a7f4d442de8bde2628346153963. Thanks Adam Johnson and Márton Salomváry for reports.
Diffstat (limited to 'tests/requests_tests')
-rw-r--r--tests/requests_tests/tests.py29
1 files changed, 16 insertions, 13 deletions
diff --git a/tests/requests_tests/tests.py b/tests/requests_tests/tests.py
index ef218afe2f..d3e9e66224 100644
--- a/tests/requests_tests/tests.py
+++ b/tests/requests_tests/tests.py
@@ -1,4 +1,4 @@
-import pickle
+import copy
from io import BytesIO
from itertools import chain
from urllib.parse import urlencode
@@ -233,6 +233,11 @@ class RequestsTests(SimpleTestCase):
# left percent-encoded in the path.
self.assertEqual(request.path, "/caf%E9/")
+ def test_wsgirequest_copy(self):
+ request = WSGIRequest({"REQUEST_METHOD": "get", "wsgi.input": BytesIO(b"")})
+ request_copy = copy.copy(request)
+ self.assertIs(request_copy.environ, request.environ)
+
def test_limited_stream(self):
# Read all of a limited stream
stream = LimitedStream(BytesIO(b"test"), 2)
@@ -687,19 +692,17 @@ class RequestsTests(SimpleTestCase):
with self.assertRaises(UnreadablePostError):
request.FILES
- def test_pickling_request(self):
+ def test_copy(self):
request = HttpRequest()
- request.method = "GET"
- request.path = "/testpath/"
- request.META = {
- "QUERY_STRING": ";some=query&+query=string",
- "SERVER_NAME": "example.com",
- "SERVER_PORT": 80,
- }
- request.COOKIES = {"post-key": "post-value"}
- dump = pickle.dumps(request)
- request_from_pickle = pickle.loads(dump)
- self.assertEqual(repr(request), repr(request_from_pickle))
+ request_copy = copy.copy(request)
+ self.assertIs(request_copy.resolver_match, request.resolver_match)
+
+ def test_deepcopy(self):
+ request = RequestFactory().get("/")
+ request.session = {}
+ request_copy = copy.deepcopy(request)
+ request.session["key"] = "value"
+ self.assertEqual(request_copy.session, {})
class HostValidationTests(SimpleTestCase):