mirror of
https://github.com/django/django.git
synced 2025-10-24 14:16:09 +00:00
Fixed #11012: don't needless convert cache values to unicode.
This means you can now successfully store binary blogs, such as compressed data, in the cache. Thanks to Matt Croydon for the final patch. git-svn-id: http://code.djangoproject.com/svn/django/trunk@12637 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
10
tests/regressiontests/cache/tests.py
vendored
10
tests/regressiontests/cache/tests.py
vendored
@@ -295,6 +295,16 @@ class BaseCacheTests(object):
|
||||
self.cache.set(key, value)
|
||||
self.assertEqual(self.cache.get(key), value)
|
||||
|
||||
def test_binary_string(self):
|
||||
# Binary strings should be cachable
|
||||
from zlib import compress, decompress
|
||||
value = 'value_to_be_compressed'
|
||||
compressed_value = compress(value)
|
||||
self.cache.set('binary1', compressed_value)
|
||||
compressed_result = self.cache.get('binary1')
|
||||
self.assertEqual(compressed_value, compressed_result)
|
||||
self.assertEqual(value, decompress(compressed_result))
|
||||
|
||||
def test_set_many(self):
|
||||
# Multiple keys can be set using set_many
|
||||
self.cache.set_many({"key1": "spam", "key2": "eggs"})
|
||||
|
||||
Reference in New Issue
Block a user