diff options
| author | Alex Gaynor <alex.gaynor@gmail.com> | 2013-11-03 09:51:49 -0800 |
|---|---|---|
| committer | Alex Gaynor <alex.gaynor@gmail.com> | 2013-11-03 09:51:49 -0800 |
| commit | 7288e1b02b2504b1694fe14df2d81e6a354c5610 (patch) | |
| tree | a4bb2a34ffc03d4939c6d8f961bddc1918b8fd9c /tests/cache | |
| parent | 91078f566904e49fbf99ec6375ba627e821f6143 (diff) | |
| parent | 4f151da1e5e9bf527548a5737d9cd314e3abc68e (diff) | |
Merge pull request #1852 from jasonamyers/cleanup/PEP8
Cleanup/pep8 tests
Diffstat (limited to 'tests/cache')
| -rw-r--r-- | tests/cache/closeable_cache.py | 1 | ||||
| -rw-r--r-- | tests/cache/liberal_backend.py | 1 | ||||
| -rw-r--r-- | tests/cache/models.py | 1 | ||||
| -rw-r--r-- | tests/cache/tests.py | 6 |
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, |
