summaryrefslogtreecommitdiff
path: root/tests/httpwrappers
diff options
context:
space:
mode:
authorTim Graham <timograham@gmail.com>2014-10-31 14:26:27 -0400
committerTim Graham <timograham@gmail.com>2014-11-12 19:04:45 +0100
commit42b5e4feeacf7cfa57867bf9fd5a6046de8c1cd3 (patch)
tree41ab0e055e2c3a5870572b4b70ec7e89112a5784 /tests/httpwrappers
parent4e9a6c94e6bea805e089df2dee2d4ab2c902c827 (diff)
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.
Diffstat (limited to 'tests/httpwrappers')
-rw-r--r--tests/httpwrappers/tests.py16
1 files changed, 14 insertions, 2 deletions
diff --git a/tests/httpwrappers/tests.py b/tests/httpwrappers/tests.py
index 4e705e2aeb..cc324b76cd 100644
--- a/tests/httpwrappers/tests.py
+++ b/tests/httpwrappers/tests.py
@@ -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)