summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Graham <timograham@gmail.com>2015-01-19 15:12:57 -0500
committerTim Graham <timograham@gmail.com>2015-01-19 15:12:57 -0500
commitb19b81b3960ec2090d40be65547502a3386a769b (patch)
tree6753fd777a0c9f857ae81ba433a27beee80f8f31
parentf6019312ba90b4a4c166bea25a36073e8be2016e (diff)
downloaddjango-b19b81b3960ec2090d40be65547502a3386a769b.tar.gz
Fixed #24153 -- Fixed cookie test compatibility with Python 3.4.3+
-rw-r--r--django/contrib/sessions/tests.py5
-rw-r--r--tests/requests/tests.py3
2 files changed, 5 insertions, 3 deletions
diff --git a/django/contrib/sessions/tests.py b/django/contrib/sessions/tests.py
index 097cded2f0..24d7ac7367 100644
--- a/django/contrib/sessions/tests.py
+++ b/django/contrib/sessions/tests.py
@@ -24,6 +24,7 @@ from django.test.utils import patch_logger
from django.utils import six
from django.utils import timezone
from django.utils.encoding import force_text
+from django.utils.six.moves import http_cookies
from django.contrib.sessions.exceptions import InvalidSessionKey
@@ -543,7 +544,7 @@ class SessionMiddlewareTests(unittest.TestCase):
response = middleware.process_response(request, response)
self.assertTrue(
response.cookies[settings.SESSION_COOKIE_NAME]['httponly'])
- self.assertIn('httponly',
+ self.assertIn(http_cookies.Morsel._reserved['httponly'],
str(response.cookies[settings.SESSION_COOKIE_NAME]))
@override_settings(SESSION_COOKIE_HTTPONLY=False)
@@ -560,7 +561,7 @@ class SessionMiddlewareTests(unittest.TestCase):
response = middleware.process_response(request, response)
self.assertFalse(response.cookies[settings.SESSION_COOKIE_NAME]['httponly'])
- self.assertNotIn('httponly',
+ self.assertNotIn(http_cookies.Morsel._reserved['httponly'],
str(response.cookies[settings.SESSION_COOKIE_NAME]))
def test_session_save_on_500(self):
diff --git a/tests/requests/tests.py b/tests/requests/tests.py
index bb36af3747..306e5e76bb 100644
--- a/tests/requests/tests.py
+++ b/tests/requests/tests.py
@@ -16,6 +16,7 @@ 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 import http_cookies
from django.utils.six.moves.urllib.parse import urlencode as original_urlencode
from django.utils.timezone import utc
@@ -221,7 +222,7 @@ class RequestsTests(SimpleTestCase):
example_cookie = response.cookies['example']
# A compat cookie may be in use -- check that it has worked
# both as an output string, and using the cookie attributes
- self.assertIn('; httponly', str(example_cookie))
+ self.assertIn('; %s' % http_cookies.Morsel._reserved['httponly'], str(example_cookie))
self.assertTrue(example_cookie['httponly'])
def test_unicode_cookie(self):