From 3e935aec6d6c670b3e48425d60ec94fc96f5cdd6 Mon Sep 17 00:00:00 2001 From: Ed Morley Date: Fri, 2 Sep 2016 09:33:59 +0100 Subject: [PATCH] Refs #5133 -- Tested memcached connection closing after each request. --- tests/cache/tests.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tests/cache/tests.py b/tests/cache/tests.py index 04c523e853..f9190ed55f 100644 --- a/tests/cache/tests.py +++ b/tests/cache/tests.py @@ -1239,6 +1239,13 @@ class BaseMemcachedTests(BaseCacheTests): value = cache.get('small_value') self.assertTrue(value is None or value == large_value) + def test_close(self): + # For clients that don't manage their connections properly, the + # connection is closed when the request is complete. + with mock.patch.object(cache._lib.Client, 'disconnect_all', autospec=True) as mock_disconnect: + signals.request_finished.send(self.__class__) + self.assertIs(mock_disconnect.called, True) + @unittest.skipUnless(MemcachedCache_params, "MemcachedCache backend not configured") @override_settings(CACHES=caches_setting_for_tests(