Commit d8743562 authored by Sean Bleier's avatar Sean Bleier

Merge pull request #81 from sebleier/python-3-error

Python 3 error
parents 0b3b7d0a 2621370d
......@@ -105,8 +105,8 @@ class BaseRedisCache(BaseCache):
parser_class = getattr(mod, cls_name)
except AttributeError:
raise ImproperlyConfigured("Could not find parser class '%s'" % parser_class)
except ImportError, e:
raise ImproperlyConfigured("Could not find module '%s'" % e)
except ImportError as ex:
raise ImproperlyConfigured("Could not find module '%s'" % ex)
return parser_class
def get_pickle_version(self):
......
......@@ -3,8 +3,12 @@ from hashlib import md5
from math import log
import sys
try:
maxint = sys.maxint
except AttributeError:
maxint = sys.maxsize
DIGITS = int(log(sys.maxint) / log(16))
DIGITS = int(log(maxint) / log(16))
def make_hash(s):
......
......@@ -8,6 +8,12 @@ try:
except ImportError:
import pickle
from django.core.cache import get_cache
from django.core.exceptions import ImproperlyConfigured
from django.test import TestCase
try:
from django.test import override_settings
except ImportError:
from django.test.utils import override_settings
import redis
......@@ -16,6 +22,9 @@ from redis_cache.cache import RedisCache, pool
from redis_cache.compat import DEFAULT_TIMEOUT
LOCATION = "127.0.0.1:6381"
# functions/classes for complex data type tests
def f():
return 42
......@@ -493,3 +502,28 @@ class BaseRedisTestCase(SetupMixin):
self.cache.expire('a', 20)
ttl = self.cache.ttl('a')
self.assertAlmostEqual(ttl, 20)
class ConfigurationTestCase(SetupMixin, TestCase):
@override_settings(
CACHES={
'default': {
'BACKEND': 'redis_cache.RedisCache',
'LOCATION': LOCATION,
'OPTIONS': {
'DB': 15,
'PASSWORD': 'yadayada',
'PARSER_CLASS': 'path.to.unknown.class',
'PICKLE_VERSION': 2,
'CONNECTION_POOL_CLASS': 'redis.ConnectionPool',
'CONNECTION_POOL_CLASS_KWARGS': {
'max_connections': 2,
}
},
},
}
)
def test_bad_parser_import(self):
with self.assertRaises(ImproperlyConfigured):
get_cache('default')
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment