Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Used settings config for memcached tests.

By using settings config, we take advantage of custom settings like
KEY_PREFIX which allows for example to run tests in parallel.
  • Loading branch information...
commit 37e05357cd16e008f32d5651b6c11390a8bec2e5 1 parent f7c2e82
@claudep claudep authored
Showing with 9 additions and 8 deletions.
  1. +9 −8 tests/regressiontests/cache/tests.py
View
17 tests/regressiontests/cache/tests.py
@@ -6,7 +6,9 @@
import hashlib
import os
+import random
import re
+import string
import tempfile
import time
import warnings
@@ -939,18 +941,17 @@ def test_incr_decr_timeout(self):
for cache in settings.CACHES.values()),
"memcached not available")
class MemcachedCacheTests(unittest.TestCase, BaseCacheTests):
- backend_name = 'django.core.cache.backends.memcached.MemcachedCache'
def setUp(self):
- for cache in settings.CACHES.values():
+ for cache_key, cache in settings.CACHES.items():
if cache['BACKEND'].startswith('django.core.cache.backends.memcached.'):
- name = cache['LOCATION']
break
- self.cache = get_cache(self.backend_name, LOCATION=name)
- 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.custom_key_cache = get_cache(self.backend_name, LOCATION=name, KEY_FUNCTION=custom_key_func)
- self.custom_key_cache2 = get_cache(self.backend_name, LOCATION=name, KEY_FUNCTION='regressiontests.cache.tests.custom_key_func')
+ random_prefix = ''.join(random.choice(string.ascii_letters) for x in range(10))
+ self.cache = get_cache(cache_key)
+ self.prefix_cache = get_cache(cache_key, KEY_PREFIX=random_prefix)
+ self.v2_cache = get_cache(cache_key, VERSION=2)
+ self.custom_key_cache = get_cache(cache_key, KEY_FUNCTION=custom_key_func)
+ self.custom_key_cache2 = get_cache(cache_key, KEY_FUNCTION='regressiontests.cache.tests.custom_key_func')
def tearDown(self):
self.cache.clear()
Please sign in to comment.
Something went wrong with that request. Please try again.