Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed tests introduced in previous commit on Python 2. Refs #20557.

  • Loading branch information...
commit f5add4712f684a78215263771b8acaeb48e64a81 1 parent 8aaca65
Aymeric Augustin aaugustin authored
Showing with 8 additions and 3 deletions.
  1. +8 −3 tests/handlers/tests.py
11 tests/handlers/tests.py
View
@@ -1,3 +1,5 @@
+# coding: utf-8
+
from __future__ import unicode_literals
from django.core.handlers.wsgi import WSGIHandler, WSGIRequest
@@ -5,6 +7,7 @@
from django.db import close_old_connections, connection
from django.test import RequestFactory, TestCase, TransactionTestCase
from django.test.utils import override_settings
+from django.utils.encoding import force_str
from django.utils import six
@@ -41,10 +44,12 @@ def test_bad_path_info(self):
def test_non_ascii_cookie(self):
"""Test that non-ASCII cookies set in JavaScript are properly decoded (#20557)."""
environ = RequestFactory().get('/').environ
- raw_cookie = 'want="café"'.encode('utf-8')
- environ['HTTP_COOKIE'] = raw_cookie if six.PY2 else raw_cookie.decode('iso-8859-1')
+ raw_cookie = 'want="café"'
+ if six.PY3:
+ raw_cookie = raw_cookie.encode('utf-8').decode('iso-8859-1')
+ environ['HTTP_COOKIE'] = raw_cookie
request = WSGIRequest(environ)
- self.assertEqual(request.COOKIES['want'], "café")
+ self.assertEqual(request.COOKIES['want'], force_str("café"))
class TransactionsPerRequestTests(TransactionTestCase):
Please sign in to comment.
Something went wrong with that request. Please try again.