mirror of
https://github.com/django/django.git
synced 2025-08-04 19:08:28 +00:00
Fixed #23730 -- Moved support for SimpleCookie HIGHEST_PROTOCOL pickling to http.cookie.
This fix is necessary for Python 3.5 compatibility (refs #23763). Thanks Berker Peksag for review.
This commit is contained in:
parent
4e9a6c94e6
commit
42b5e4feea
4 changed files with 34 additions and 15 deletions
|
@ -631,7 +631,7 @@ class CookieTests(unittest.TestCase):
|
|||
c = SimpleCookie()
|
||||
c['test'] = "An,awkward;value"
|
||||
c2 = SimpleCookie()
|
||||
c2.load(c.output())
|
||||
c2.load(c.output()[12:])
|
||||
self.assertEqual(c['test'].value, c2['test'].value)
|
||||
|
||||
def test_decode_2(self):
|
||||
|
@ -641,7 +641,7 @@ class CookieTests(unittest.TestCase):
|
|||
c = SimpleCookie()
|
||||
c['test'] = b"\xf0"
|
||||
c2 = SimpleCookie()
|
||||
c2.load(c.output())
|
||||
c2.load(c.output()[12:])
|
||||
self.assertEqual(c['test'].value, c2['test'].value)
|
||||
|
||||
def test_nonstandard_keys(self):
|
||||
|
@ -678,3 +678,15 @@ class CookieTests(unittest.TestCase):
|
|||
r = HttpResponse()
|
||||
r.set_cookie("a:.b/", 1)
|
||||
self.assertEqual(len(r.cookies.bad_cookies), 1)
|
||||
|
||||
def test_pickle(self):
|
||||
rawdata = 'Customer="WILE_E_COYOTE"; Path=/acme; Version=1'
|
||||
expected_output = 'Set-Cookie: %s' % rawdata
|
||||
|
||||
C = SimpleCookie()
|
||||
C.load(rawdata)
|
||||
self.assertEqual(C.output(), expected_output)
|
||||
|
||||
for proto in range(pickle.HIGHEST_PROTOCOL + 1):
|
||||
C1 = pickle.loads(pickle.dumps(C, protocol=proto))
|
||||
self.assertEqual(C1.output(), expected_output)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue