diff options
| author | Adam Johnson <me@adamj.eu> | 2017-10-30 15:30:00 +0000 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2017-10-31 12:16:09 -0400 |
| commit | acc989f037f4185b3f55cb76ab51c5224f30f0d1 (patch) | |
| tree | 0834c2f75f3bde6b130141436068ed63ed597399 /tests/cache | |
| parent | 23e551ce6c7956e4c143357643dab2e89d30bfe0 (diff) | |
Fixed #28760 -- Removed DummyCache's unnecessary get/set/delete_many().
Diffstat (limited to 'tests/cache')
| -rw-r--r-- | tests/cache/tests.py | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/tests/cache/tests.py b/tests/cache/tests.py index 5cee2d84a5..63e0c8a02e 100644 --- a/tests/cache/tests.py +++ b/tests/cache/tests.py @@ -59,6 +59,12 @@ class Unpicklable: raise pickle.PickleError() +KEY_ERRORS_WITH_MEMCACHED_MSG = ( + 'Cache key contains characters that will cause errors if used with ' + 'memcached: %r' +) + + @override_settings(CACHES={ 'default': { 'BACKEND': 'django.core.cache.backends.dummy.DummyCache', @@ -94,6 +100,10 @@ class DummyCacheTests(SimpleTestCase): self.assertEqual(cache.get_many(['a', 'c', 'd']), {}) self.assertEqual(cache.get_many(['a', 'b', 'e']), {}) + def test_get_many_invalid_key(self): + with self.assertWarns(CacheKeyWarning, msg=KEY_ERRORS_WITH_MEMCACHED_MSG % 'key with spaces'): + cache.get_many(['key with spaces']) + def test_delete(self): "Cache deletion is transparently ignored on the dummy cache backend" cache.set("key1", "spam") @@ -176,10 +186,18 @@ class DummyCacheTests(SimpleTestCase): self.assertEqual(cache.set_many({'a': 1, 'b': 2}), []) self.assertEqual(cache.set_many({'a': 1, 'b': 2}, timeout=2, version='1'), []) + def test_set_many_invalid_key(self): + with self.assertWarns(CacheKeyWarning, msg=KEY_ERRORS_WITH_MEMCACHED_MSG % 'key with spaces'): + cache.set_many({'key with spaces': 'foo'}) + def test_delete_many(self): "delete_many does nothing for the dummy cache backend" cache.delete_many(['a', 'b']) + def test_delete_many_invalid_key(self): + with self.assertWarns(CacheKeyWarning, msg=KEY_ERRORS_WITH_MEMCACHED_MSG % 'key with spaces'): + cache.delete_many({'key with spaces': 'foo'}) + def test_clear(self): "clear does nothing for the dummy cache backend" cache.clear() @@ -596,11 +614,7 @@ class BaseCacheTests: def test_invalid_key_characters(self): # memcached doesn't allow whitespace or control characters in keys. key = 'key with spaces and 清' - expected_warning = ( - "Cache key contains characters that will cause errors if used " - "with memcached: %r" % key - ) - self._perform_invalid_key_test(key, expected_warning) + self._perform_invalid_key_test(key, KEY_ERRORS_WITH_MEMCACHED_MSG % key) def test_invalid_key_length(self): # memcached limits key length to 250. |
