mirror of
https://github.com/django/django.git
synced 2025-10-23 21:59:11 +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:
22
tests/regressiontests/cache/tests.py
vendored
22
tests/regressiontests/cache/tests.py
vendored
@@ -2,7 +2,7 @@
|
||||
|
||||
# Unit tests for cache framework
|
||||
# Uses whatever cache backend is set in the test settings file.
|
||||
from __future__ import absolute_import
|
||||
from __future__ import absolute_import, unicode_literals
|
||||
|
||||
import hashlib
|
||||
import os
|
||||
@@ -139,10 +139,10 @@ class DummyCacheTests(unittest.TestCase):
|
||||
def test_unicode(self):
|
||||
"Unicode values are ignored by the dummy cache"
|
||||
stuff = {
|
||||
u'ascii': u'ascii_value',
|
||||
u'unicode_ascii': u'Iñtërnâtiônàlizætiøn1',
|
||||
u'Iñtërnâtiônàlizætiøn': u'Iñtërnâtiônàlizætiøn2',
|
||||
u'ascii2': {u'x' : 1 }
|
||||
'ascii': 'ascii_value',
|
||||
'unicode_ascii': 'Iñtërnâtiônàlizætiøn1',
|
||||
'Iñtërnâtiônàlizætiøn': 'Iñtërnâtiônàlizætiøn2',
|
||||
'ascii2': {'x' : 1 }
|
||||
}
|
||||
for (key, value) in stuff.items():
|
||||
self.cache.set(key, value)
|
||||
@@ -337,10 +337,10 @@ class BaseCacheTests(object):
|
||||
def test_unicode(self):
|
||||
# Unicode values can be cached
|
||||
stuff = {
|
||||
u'ascii': u'ascii_value',
|
||||
u'unicode_ascii': u'Iñtërnâtiônàlizætiøn1',
|
||||
u'Iñtërnâtiônàlizætiøn': u'Iñtërnâtiônàlizætiøn2',
|
||||
u'ascii2': {u'x' : 1 }
|
||||
'ascii': 'ascii_value',
|
||||
'unicode_ascii': 'Iñtërnâtiônàlizætiøn1',
|
||||
'Iñtërnâtiônàlizætiøn': 'Iñtërnâtiônàlizætiøn2',
|
||||
'ascii2': {'x' : 1 }
|
||||
}
|
||||
# Test `set`
|
||||
for (key, value) in stuff.items():
|
||||
@@ -1337,12 +1337,12 @@ class CacheI18nTest(TestCase):
|
||||
request = self._get_request()
|
||||
response = HttpResponse()
|
||||
with timezone.override(CustomTzName()):
|
||||
CustomTzName.name = 'Hora estándar de Argentina' # UTF-8 string
|
||||
CustomTzName.name = 'Hora estándar de Argentina'.encode('UTF-8') # UTF-8 string
|
||||
sanitized_name = 'Hora_estndar_de_Argentina'
|
||||
self.assertIn(sanitized_name, learn_cache_key(request, response),
|
||||
"Cache keys should include the time zone name when time zones are active")
|
||||
|
||||
CustomTzName.name = u'Hora estándar de Argentina' # unicode
|
||||
CustomTzName.name = 'Hora estándar de Argentina' # unicode
|
||||
sanitized_name = 'Hora_estndar_de_Argentina'
|
||||
self.assertIn(sanitized_name, learn_cache_key(request, response),
|
||||
"Cache keys should include the time zone name when time zones are active")
|
||||
|
||||
Reference in New Issue
Block a user