1
0
mirror of https://github.com/django/django.git synced 2025-10-24 14:16:09 +00:00

Fixed #32969 -- Fixed pickling HttpResponse and subclasses.

This commit is contained in:
Anv3sh
2022-06-16 21:34:13 +05:30
committed by Mariusz Felisiak
parent 901a169198
commit d7f5bfd241
7 changed files with 51 additions and 9 deletions

View File

@@ -20,6 +20,7 @@ rather than the HTML rendered to the end-user.
"""
import itertools
import pickle
import tempfile
from unittest import mock
@@ -80,6 +81,21 @@ class ClientTest(TestCase):
self.assertEqual(response.context["var"], "\xf2")
self.assertEqual(response.templates[0].name, "GET Template")
def test_pickling_response(self):
tests = ["/cbv_view/", "/get_view/"]
for url in tests:
with self.subTest(url=url):
response = self.client.get(url)
dump = pickle.dumps(response)
response_from_pickle = pickle.loads(dump)
self.assertEqual(repr(response), repr(response_from_pickle))
async def test_pickling_response_async(self):
response = await self.async_client.get("/async_get_view/")
dump = pickle.dumps(response)
response_from_pickle = pickle.loads(dump)
self.assertEqual(repr(response), repr(response_from_pickle))
def test_query_string_encoding(self):
# WSGI requires latin-1 encoded strings.
response = self.client.get("/get_view/?var=1\ufffd")