summaryrefslogtreecommitdiff
path: root/tests/cache
diff options
context:
space:
mode:
authorJason Myers <jason@jasonamyers.com>2013-11-02 23:36:09 -0500
committerJason Myers <jason@jasonamyers.com>2013-11-02 23:50:49 -0500
commit7a61c68c50d3837c50e35c252fd76220f08b5290 (patch)
tree586f16a3f02c2b45ffb3dd2af834c0ef604e099c /tests/cache
parent0fdb692c6c94d912f17a3e2ad12413fb072d38ec (diff)
PEP8 cleanup
Signed-off-by: Jason Myers <jason@jasonamyers.com>
Diffstat (limited to 'tests/cache')
-rw-r--r--tests/cache/closeable_cache.py1
-rw-r--r--tests/cache/liberal_backend.py1
-rw-r--r--tests/cache/models.py1
-rw-r--r--tests/cache/tests.py6
4 files changed, 9 insertions, 0 deletions
diff --git a/tests/cache/closeable_cache.py b/tests/cache/closeable_cache.py
index 83073850b7..1ac868dde9 100644
--- a/tests/cache/closeable_cache.py
+++ b/tests/cache/closeable_cache.py
@@ -7,5 +7,6 @@ class CloseHookMixin(object):
def close(self, **kwargs):
self.closed = True
+
class CacheClass(CloseHookMixin, LocMemCache):
pass
diff --git a/tests/cache/liberal_backend.py b/tests/cache/liberal_backend.py
index 3e3ce3beeb..339066b0ff 100644
--- a/tests/cache/liberal_backend.py
+++ b/tests/cache/liberal_backend.py
@@ -5,5 +5,6 @@ class LiberalKeyValidationMixin(object):
def validate_key(self, key):
pass
+
class CacheClass(LiberalKeyValidationMixin, LocMemCache):
pass
diff --git a/tests/cache/models.py b/tests/cache/models.py
index 2cd648b780..4fccbb664b 100644
--- a/tests/cache/models.py
+++ b/tests/cache/models.py
@@ -7,6 +7,7 @@ def expensive_calculation():
expensive_calculation.num_runs += 1
return timezone.now()
+
class Poll(models.Model):
question = models.CharField(max_length=200)
answer = models.CharField(max_length=200)
diff --git a/tests/cache/tests.py b/tests/cache/tests.py
index a79d4d9fac..a93ed4418a 100644
--- a/tests/cache/tests.py
+++ b/tests/cache/tests.py
@@ -40,10 +40,12 @@ from django.views.decorators.cache import cache_page
from .models import Poll, expensive_calculation
+
# functions/classes for complex data type tests
def f():
return 42
+
class C:
def m(n):
return 24
@@ -823,6 +825,7 @@ class BaseCacheTests(object):
self.assertEqual(get_cache_data.content, content.encode('utf-8'))
self.assertEqual(get_cache_data.cookies, response.cookies)
+
def custom_key_func(key, key_prefix, version):
"A customized cache key function"
return 'CUSTOM-' + '-'.join([key_prefix, str(version), key])
@@ -1004,6 +1007,7 @@ class LocMemCacheTests(unittest.TestCase, BaseCacheTests):
self.cache.decr(key)
self.assertEqual(expire, self.cache._expire_info[_key])
+
# memcached backend isn't guaranteed to be available.
# To check the memcached backend, the test settings file will
# need to contain at least one cache backend setting that points at
@@ -1581,6 +1585,7 @@ class CacheI18nTest(TestCase):
get_cache_data = FetchFromCacheMiddleware().process_request(request)
self.assertIsNone(get_cache_data)
+
@override_settings(
CACHES={
'default': {
@@ -1816,6 +1821,7 @@ class CacheMiddlewareTest(IgnoreDeprecationWarningsMixin, TestCase):
response = other_with_prefix_view(request, '16')
self.assertEqual(response.content, b'Hello World 16')
+
@override_settings(
CACHE_MIDDLEWARE_KEY_PREFIX='settingsprefix',
CACHE_MIDDLEWARE_SECONDS=1,