Commit 558c2a4b authored by Sean Bleier's avatar Sean Bleier

Make update for django 1.8.

parent 8e9d345a
from django.core.cache.backends.base import BaseCache, InvalidCacheBackendError
from django.core.exceptions import ImproperlyConfigured
from django.utils import importlib
from django.utils.datastructures import SortedDict
from .compat import (smart_text, smart_bytes, bytes_type,
python_2_unicode_compatible, DEFAULT_TIMEOUT)
try:
import importlib
except ImportError:
from django.utils import importlib
try:
import cPickle as pickle
except ImportError:
......@@ -49,8 +53,9 @@ class CacheConnectionPool(object):
password=None, parser_class=None,
unix_socket_path=None, connection_pool_class=None,
connection_pool_class_kwargs=None):
connection_identifier = (host, port, db, parser_class, unix_socket_path, connection_pool_class)
if not self._connection_pools.get(connection_identifier):
connection_identifier = (host, port, db, unix_socket_path)
pool = self._connection_pools.get(connection_identifier)
if pool is None:
connection_class = (
unix_socket_path and UnixDomainSocketConnection or Connection
)
......
#!/usr/bin/env python
import sys
from os.path import dirname, abspath
from os.path import dirname, abspath, join
import django
from django.conf import settings
......@@ -10,8 +11,9 @@ cache_settings = {
'ENGINE': 'django.db.backends.sqlite3',
}
},
'MIDDLEWARE_CLASSES':(),
'INSTALLED_APPS': [
'tests.testapp',
'testapp',
],
'ROOT_URLCONF': 'tests.urls',
'CACHES': {
......@@ -34,14 +36,21 @@ cache_settings = {
if not settings.configured:
settings.configure(**cache_settings)
from django.test.simple import DjangoTestSuiteRunner
try:
from django.test.simple import DjangoTestSuiteRunner as TestSuiteRunner
except ImportError:
from django.test.runner import DiscoverRunner as TestSuiteRunner
def runtests(*test_args):
if not test_args:
test_args = ['testapp']
parent = dirname(abspath(__file__))
sys.path.insert(0, parent)
runner = DjangoTestSuiteRunner(verbosity=1, interactive=True, failfast=False)
sys.path.insert(0, join(dirname(abspath(__file__)), 'tests'))
try:
django.setup()
except AttributeError:
pass
runner = TestSuiteRunner(verbosity=1, interactive=True, failfast=False)
failures = runner.run_tests(test_args)
sys.exit(failures)
......
......@@ -45,8 +45,10 @@ class RedisCacheTests(TestCase):
def get_cache(self, backend=None):
if VERSION[0] == 1 and VERSION[1] < 3:
cache = get_cache(backend or 'redis_cache.cache://127.0.0.1:6379?db=15')
elif VERSION[0] == 1 and VERSION[1] >= 3:
elif VERSION[0] == 1 and VERSION[1] >= 3 and VERSION[1] <= 7:
cache = get_cache(backend or 'default')
else:
cache = get_cache(backend or 'redis_cache.cache.CacheClass', LOCATION='127.0.0.1:6379')
return cache
def test_bad_db_initialization(self):
......@@ -356,11 +358,11 @@ class RedisCacheTests(TestCase):
def test_multiple_connection_pool_connections(self):
pool._connection_pools = {}
get_cache('redis_cache.cache://127.0.0.1:6379?db=15')
get_cache('redis_cache.cache.CacheClass', LOCATION='127.0.0.1:6379', OPTIONS={'DB': 15})
self.assertEqual(len(pool._connection_pools), 1)
get_cache('redis_cache.cache://127.0.0.1:6379?db=14')
get_cache('redis_cache.cache.CacheClass', LOCATION='127.0.0.1:6379', OPTIONS={'DB': 14})
self.assertEqual(len(pool._connection_pools), 2)
get_cache('redis_cache.cache://127.0.0.1:6379?db=15')
get_cache('redis_cache.cache.CacheClass', LOCATION='127.0.0.1:6379', OPTIONS={'DB': 15})
self.assertEqual(len(pool._connection_pools), 2)
def test_setting_string_integer_retrieves_string(self):
......
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