summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorqingfeng <qingfenghello@gmail.com>2014-08-02 00:29:59 +0800
committerTim Graham <timograham@gmail.com>2014-08-03 12:50:25 -0400
commit0d23450e81dc355c354a873fe187687e4aaa4886 (patch)
treef8748da3fb67d1e150b1e1d79b0af51be2cd5166 /tests
parent0f2ceee0254349ee4ac7d472d3efe67ee161a917 (diff)
Fixed #19802 -- Fixed HttpResponse.set_cookie() with unicode data on Python 2.
Thanks django at patrickbregman.eu for the report.
Diffstat (limited to 'tests')
-rw-r--r--tests/requests/tests.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/tests/requests/tests.py b/tests/requests/tests.py
index 1eea1be439..b8291d8359 100644
--- a/tests/requests/tests.py
+++ b/tests/requests/tests.py
@@ -14,6 +14,7 @@ from django.test import SimpleTestCase, RequestFactory, override_settings
from django.test.client import FakePayload
from django.test.utils import str_prefix
from django.utils import six
+from django.utils.encoding import force_str
from django.utils.http import cookie_date, urlencode
from django.utils.six.moves.urllib.parse import urlencode as original_urlencode
from django.utils.timezone import utc
@@ -193,6 +194,13 @@ class RequestsTests(SimpleTestCase):
self.assertTrue('; httponly' in str(example_cookie))
self.assertTrue(example_cookie['httponly'])
+ def test_unicode_cookie(self):
+ "Verify HttpResponse.set_cookie() works with unicode data."
+ response = HttpResponse()
+ cookie_value = '清風'
+ response.set_cookie('test', cookie_value)
+ self.assertEqual(force_str(cookie_value), response.cookies['test'].value)
+
def test_limited_stream(self):
# Read all of a limited stream
stream = LimitedStream(BytesIO(b'test'), 2)