From ec2f6ea9c6203524933e08d069733cd00a09ede3 Mon Sep 17 00:00:00 2001 From: Mariusz Felisiak Date: Fri, 3 Sep 2021 11:13:39 +0200 Subject: [PATCH] Refs #33060 -- Added memcached test for make_key() making keys invalid. --- tests/cache/tests.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tests/cache/tests.py b/tests/cache/tests.py index f2b70a4919..1b40def85a 100644 --- a/tests/cache/tests.py +++ b/tests/cache/tests.py @@ -1417,6 +1417,15 @@ class BaseMemcachedTests(BaseCacheTests): getattr(cache, operation)(*args) self.assertEqual(str(cm.exception), msg) + def test_invalid_with_version_key_length(self): + # make_key() adds a version to the key and exceeds the limit. + key = 'a' * 248 + expected_warning = ( + 'Cache key will cause errors if used with memcached: ' + '%r (longer than %s)' % (key, 250) + ) + self._perform_invalid_key_test(key, expected_warning) + def test_default_never_expiring_timeout(self): # Regression test for #22845 with self.settings(CACHES=caches_setting_for_tests(