summaryrefslogtreecommitdiff
path: root/tests/test_memcache.py
diff options
context:
space:
mode:
authorMatt Davis <matteius@gmail.com>2017-09-05 16:03:09 -0400
committerTim Graham <timograham@gmail.com>2017-11-14 14:40:35 -0500
commitcc94e72f629a7145158def6a363ff51e56dee022 (patch)
tree26c41d4a950afd143a7e3d68decadfaec686fc59 /tests/test_memcache.py
parent2e9dcfbb8efb8726468b02a2ed79f01a18ec2c26 (diff)
downloadpython-memcached-cc94e72f629a7145158def6a363ff51e56dee022.tar.gz
Fix crash on Python 3 in touch() logging
Diffstat (limited to 'tests/test_memcache.py')
-rw-r--r--tests/test_memcache.py14
1 files changed, 13 insertions, 1 deletions
diff --git a/tests/test_memcache.py b/tests/test_memcache.py
index 6408e81..58024cd 100644
--- a/tests/test_memcache.py
+++ b/tests/test_memcache.py
@@ -2,9 +2,10 @@ from __future__ import print_function
import unittest
+import mock
import six
-from memcache import Client, SERVER_MAX_KEY_LENGTH, SERVER_MAX_VALUE_LENGTH # noqa: H301
+from memcache import Client, _Host, SERVER_MAX_KEY_LENGTH, SERVER_MAX_VALUE_LENGTH # noqa: H301
from .utils import captured_stderr
@@ -183,6 +184,17 @@ class TestMemcache(unittest.TestCase):
"'NOT_FOUND'\n"
)
+ @mock.patch.object(_Host, 'readline')
+ def test_touch_unexpected_reply(self, mock_readline):
+ """touch() logs an error upon receiving an unexpected reply."""
+ mock_readline.return_value = 'SET' # the unexpected reply
+ with captured_stderr() as output:
+ self.mc.touch('key')
+ self.assertEqual(
+ output.getvalue(),
+ "MemCached: touch expected %s, got: 'SET'\n" % b'TOUCHED'
+ )
+
if __name__ == '__main__':
unittest.main()