[py3] Properly encode hashlib.md5 and zip.compress args in the tests.

This commit is contained in:
Florian Apolloner 2012-08-15 14:29:40 +02:00
parent f2fff84bc3
commit c1584890b1
1 changed files with 3 additions and 3 deletions

View File

@ -364,7 +364,7 @@ class BaseCacheTests(object):
# Binary strings should be cacheable # Binary strings should be cacheable
from zlib import compress, decompress from zlib import compress, decompress
value = 'value_to_be_compressed' value = 'value_to_be_compressed'
compressed_value = compress(value) compressed_value = compress(value.encode())
# Test set # Test set
self.cache.set('binary1', compressed_value) self.cache.set('binary1', compressed_value)
@ -988,7 +988,7 @@ class FileBasedCacheTests(unittest.TestCase, BaseCacheTests):
"""Test that keys are hashed into subdirectories correctly""" """Test that keys are hashed into subdirectories correctly"""
self.cache.set("foo", "bar") self.cache.set("foo", "bar")
key = self.cache.make_key("foo") key = self.cache.make_key("foo")
keyhash = hashlib.md5(key).hexdigest() keyhash = hashlib.md5(key.encode()).hexdigest()
keypath = os.path.join(self.dirname, keyhash[:2], keyhash[2:4], keyhash[4:]) keypath = os.path.join(self.dirname, keyhash[:2], keyhash[2:4], keyhash[4:])
self.assertTrue(os.path.exists(keypath)) self.assertTrue(os.path.exists(keypath))
@ -998,7 +998,7 @@ class FileBasedCacheTests(unittest.TestCase, BaseCacheTests):
""" """
self.cache.set("foo", "bar") self.cache.set("foo", "bar")
key = self.cache.make_key("foo") key = self.cache.make_key("foo")
keyhash = hashlib.md5(key).hexdigest() keyhash = hashlib.md5(key.encode()).hexdigest()
keypath = os.path.join(self.dirname, keyhash[:2], keyhash[2:4], keyhash[4:]) keypath = os.path.join(self.dirname, keyhash[:2], keyhash[2:4], keyhash[4:])
self.assertTrue(os.path.exists(keypath)) self.assertTrue(os.path.exists(keypath))