[py3] Fixed encoding issues in cache key generation

This commit is contained in:
Claude Paroz 2012-08-13 12:09:20 +02:00
parent d774ad752d
commit 45baaabafb
3 changed files with 7 additions and 6 deletions

View file

@ -1308,7 +1308,7 @@ class CacheI18nTest(TestCase):
# This is tightly coupled to the implementation,
# but it's the most straightforward way to test the key.
tz = force_text(timezone.get_current_timezone_name(), errors='ignore')
tz = tz.encode('ascii', 'ignore').replace(' ', '_')
tz = tz.encode('ascii', 'ignore').decode('ascii').replace(' ', '_')
response = HttpResponse()
key = learn_cache_key(request, response)
self.assertIn(tz, key, "Cache keys should include the time zone name when time zones are active")
@ -1320,7 +1320,7 @@ class CacheI18nTest(TestCase):
request = self._get_request()
lang = translation.get_language()
tz = force_text(timezone.get_current_timezone_name(), errors='ignore')
tz = tz.encode('ascii', 'ignore').replace(' ', '_')
tz = tz.encode('ascii', 'ignore').decode('ascii').replace(' ', '_')
response = HttpResponse()
key = learn_cache_key(request, response)
self.assertNotIn(lang, key, "Cache keys shouldn't include the language name when i18n isn't active")