diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2014-11-02 20:18:25 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2014-11-02 20:18:25 (GMT) |
commit | 8cf7c1cff0f1176387118826fffdf1c517405f3a (patch) | |
tree | 3d417f11c533d4a72568492aa892aefc94e49320 /Lib/test/test_http_cookies.py | |
parent | a5c9c37dd51cdec4e858fde6a42bf6b2868cae48 (diff) | |
download | cpython-8cf7c1cff0f1176387118826fffdf1c517405f3a.zip cpython-8cf7c1cff0f1176387118826fffdf1c517405f3a.tar.gz cpython-8cf7c1cff0f1176387118826fffdf1c517405f3a.tar.bz2 |
Issue #22775: Fixed unpickling of http.cookies.SimpleCookie with protocol 2
and above. Patch by Tim Graham.
Diffstat (limited to 'Lib/test/test_http_cookies.py')
-rw-r--r-- | Lib/test/test_http_cookies.py | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/Lib/test/test_http_cookies.py b/Lib/test/test_http_cookies.py index 76e5e9c..2b0281e 100644 --- a/Lib/test/test_http_cookies.py +++ b/Lib/test/test_http_cookies.py @@ -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.""" |