Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Run memcache tests if any cache is configured

  • Loading branch information...
commit 27192564c3193a54165752e8803b4d7b635f9022 1 parent a9facb4
Claude Paroz authored August 15, 2012

Showing 1 changed file with 7 additions and 3 deletions. Show diff stats Hide diff stats

  1. 10  tests/regressiontests/cache/tests.py
10  tests/regressiontests/cache/tests.py
@@ -932,16 +932,20 @@ def test_incr_decr_timeout(self):
932 932
 
933 933
 # memcached backend isn't guaranteed to be available.
934 934
 # To check the memcached backend, the test settings file will
935  
-# need to contain a cache backend setting that points at
  935
+# need to contain at least one cache backend setting that points at
936 936
 # your memcache server.
937 937
 @unittest.skipUnless(
938  
-    settings.CACHES[DEFAULT_CACHE_ALIAS]['BACKEND'].startswith('django.core.cache.backends.memcached.'),
  938
+    any(cache['BACKEND'].startswith('django.core.cache.backends.memcached.')
  939
+        for cache in settings.CACHES.values()),
939 940
     "memcached not available")
940 941
 class MemcachedCacheTests(unittest.TestCase, BaseCacheTests):
941 942
     backend_name = 'django.core.cache.backends.memcached.MemcachedCache'
942 943
 
943 944
     def setUp(self):
944  
-        name = settings.CACHES[DEFAULT_CACHE_ALIAS]['LOCATION']
  945
+        for cache in settings.CACHES.values():
  946
+            if cache['BACKEND'].startswith('django.core.cache.backends.memcached.'):
  947
+                name = cache['LOCATION']
  948
+                break
945 949
         self.cache = get_cache(self.backend_name, LOCATION=name)
946 950
         self.prefix_cache = get_cache(self.backend_name, LOCATION=name, KEY_PREFIX='cacheprefix')
947 951
         self.v2_cache = get_cache(self.backend_name, LOCATION=name, VERSION=2)

0 notes on commit 2719256

Please sign in to comment.
Something went wrong with that request. Please try again.