mirror of
https://github.com/django/django.git
synced 2025-10-24 14:16:09 +00:00
Fixed #18269 -- Applied unicode_literals for Python 3 compatibility.
Thanks Vinay Sajip for the support of his django3 branch and Jannis Leidel for the review.
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.conf import settings
|
||||
from django.core.context_processors import csrf
|
||||
@@ -11,7 +12,7 @@ from django.views.decorators.csrf import csrf_exempt, requires_csrf_token, ensur
|
||||
|
||||
# Response/views used for CsrfResponseMiddleware and CsrfViewMiddleware tests
|
||||
def post_form_response():
|
||||
resp = HttpResponse(content=u"""
|
||||
resp = HttpResponse(content="""
|
||||
<html><body><h1>\u00a1Unicode!<form method="post"><input type="text" /></form></body></html>
|
||||
""", mimetype="text/html")
|
||||
return resp
|
||||
@@ -215,18 +216,18 @@ class CsrfViewMiddlewareTest(TestCase):
|
||||
"""
|
||||
req = self._get_GET_no_csrf_cookie_request()
|
||||
resp = token_view(req)
|
||||
self.assertEqual(u"", resp.content)
|
||||
self.assertEqual("", resp.content)
|
||||
|
||||
def test_token_node_empty_csrf_cookie(self):
|
||||
"""
|
||||
Check that we get a new token if the csrf_cookie is the empty string
|
||||
"""
|
||||
req = self._get_GET_no_csrf_cookie_request()
|
||||
req.COOKIES[settings.CSRF_COOKIE_NAME] = ""
|
||||
req.COOKIES[settings.CSRF_COOKIE_NAME] = b""
|
||||
CsrfViewMiddleware().process_view(req, token_view, (), {})
|
||||
resp = token_view(req)
|
||||
|
||||
self.assertNotEqual(u"", resp.content)
|
||||
self.assertNotEqual("", resp.content)
|
||||
|
||||
def test_token_node_with_csrf_cookie(self):
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user