Run memcache tests if any cache is configured
This commit is contained in:
parent
a9facb455f
commit
27192564c3
|
@ -932,16 +932,20 @@ class LocMemCacheTests(unittest.TestCase, BaseCacheTests):
|
||||||
|
|
||||||
# memcached backend isn't guaranteed to be available.
|
# memcached backend isn't guaranteed to be available.
|
||||||
# To check the memcached backend, the test settings file will
|
# To check the memcached backend, the test settings file will
|
||||||
# need to contain a cache backend setting that points at
|
# need to contain at least one cache backend setting that points at
|
||||||
# your memcache server.
|
# your memcache server.
|
||||||
@unittest.skipUnless(
|
@unittest.skipUnless(
|
||||||
settings.CACHES[DEFAULT_CACHE_ALIAS]['BACKEND'].startswith('django.core.cache.backends.memcached.'),
|
any(cache['BACKEND'].startswith('django.core.cache.backends.memcached.')
|
||||||
|
for cache in settings.CACHES.values()),
|
||||||
"memcached not available")
|
"memcached not available")
|
||||||
class MemcachedCacheTests(unittest.TestCase, BaseCacheTests):
|
class MemcachedCacheTests(unittest.TestCase, BaseCacheTests):
|
||||||
backend_name = 'django.core.cache.backends.memcached.MemcachedCache'
|
backend_name = 'django.core.cache.backends.memcached.MemcachedCache'
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
name = settings.CACHES[DEFAULT_CACHE_ALIAS]['LOCATION']
|
for cache in settings.CACHES.values():
|
||||||
|
if cache['BACKEND'].startswith('django.core.cache.backends.memcached.'):
|
||||||
|
name = cache['LOCATION']
|
||||||
|
break
|
||||||
self.cache = get_cache(self.backend_name, LOCATION=name)
|
self.cache = get_cache(self.backend_name, LOCATION=name)
|
||||||
self.prefix_cache = get_cache(self.backend_name, LOCATION=name, KEY_PREFIX='cacheprefix')
|
self.prefix_cache = get_cache(self.backend_name, LOCATION=name, KEY_PREFIX='cacheprefix')
|
||||||
self.v2_cache = get_cache(self.backend_name, LOCATION=name, VERSION=2)
|
self.v2_cache = get_cache(self.backend_name, LOCATION=name, VERSION=2)
|
||||||
|
|
Loading…
Reference in New Issue