mirror of
https://github.com/python/cpython.git
synced 2025-09-26 10:19:53 +00:00
Issue #22775: Fixed unpickling of http.cookies.SimpleCookie with protocol 2
and above. Patch by Tim Graham.
This commit is contained in:
commit
2cb0e73a89
5 changed files with 25 additions and 4 deletions
|
@ -1284,7 +1284,7 @@ class AbstractPickleTests(unittest.TestCase):
|
|||
loaded = self.loads(DATA5)
|
||||
self.assertEqual(type(loaded), SimpleCookie)
|
||||
self.assertEqual(list(loaded.keys()), ["key"])
|
||||
self.assertEqual(loaded["key"].value, "Set-Cookie: key=value")
|
||||
self.assertEqual(loaded["key"].value, "value")
|
||||
|
||||
for (exc, data) in DATA7.items():
|
||||
loaded = self.loads(data)
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
from test.support import run_unittest, run_doctest, check_warnings
|
||||
import unittest
|
||||
from http import cookies
|
||||
|
||||
import pickle
|
||||
import warnings
|
||||
|
||||
class CookieTests(unittest.TestCase):
|
||||
|
@ -187,6 +187,19 @@ class CookieTests(unittest.TestCase):
|
|||
self.assertEqual(dict(C), {})
|
||||
self.assertEqual(C.output(), '')
|
||||
|
||||
def test_pickle(self):
|
||||
rawdata = 'Customer="WILE_E_COYOTE"; Path=/acme; Version=1'
|
||||
expected_output = 'Set-Cookie: %s' % rawdata
|
||||
|
||||
C = cookies.SimpleCookie()
|
||||
C.load(rawdata)
|
||||
self.assertEqual(C.output(), expected_output)
|
||||
|
||||
for proto in range(pickle.HIGHEST_PROTOCOL + 1):
|
||||
with self.subTest(proto=proto):
|
||||
C1 = pickle.loads(pickle.dumps(C, protocol=proto))
|
||||
self.assertEqual(C1.output(), expected_output)
|
||||
|
||||
|
||||
class MorselTests(unittest.TestCase):
|
||||
"""Tests for the Morsel object."""
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue