          with self.assertRaises(InvalidCacheKey) as cm:
              cache.set(key, 'value')
  
      def test_default_never_expiring_timeout(self):
          # Regression test for #22845
          with self.settings(CACHES=caches_setting_for_tests(
                  base=self.base_params,
 
</s> remove         with self.assertRaisesMessage(InvalidCacheKey, msg):
 </s> add         with self.assertRaises(InvalidCacheKey) as cm: </s> remove             with self.assertWarnsMessage(CacheKeyWarning, expected_warning):
 </s> add             with self.assertWarns(CacheKeyWarning) as cm: </s> remove                 'used with memcached: %r' % key, CacheKeyWarning
 </s> add                 'used with memcached: %r' % key
        self.assertEqual(str(cm.exception), msg)
          with self.assertRaises(InvalidCacheKey) as cm:
              cache.set(key, 'value')
        self.assertEqual(str(cm.exception), msg)
  
      def test_default_never_expiring_timeout(self):
          # Regression test for #22845
          with self.settings(CACHES=caches_setting_for_tests(
                  base=self.base_params,
keep add keep keep keep keep keep
 Fixed #31654 -- Fixed cache key validation messages. 
tests/cache/tests.py