summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Noé <nicolas@niconoe.eu>2016-12-14 10:44:34 +0100
committerTim Graham <timograham@gmail.com>2017-11-21 13:37:56 -0500
commit0b47212f4f2f7584a840ab3978ccdfc8f8f4fd90 (patch)
tree11828bac6d417fe532120e47a5f791eebe24e80d
parent4670752fa522d3e33db6b58a34033a3b89b9ee82 (diff)
downloadpython-memcached-0b47212f4f2f7584a840ab3978ccdfc8f8f4fd90.tar.gz
Fix touch(..., time=0) sending invalid command to memcache
Without the trailing '0', the command is invalid.
-rw-r--r--ChangeLog2
-rw-r--r--memcache.py2
-rw-r--r--tests/test_memcache.py7
3 files changed, 10 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 138e8ea..213e707 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -16,6 +16,8 @@
* Fixed storing non-ASCII values on Python 2 and binary values on Python 3
(PR from Nicolas Noé) #135
+ * Fixed touch(..., time=0) command (PR from Nicolas Noé) #137
+
Fri, 27 May 2016 13:44:55 -0600 Sean Reifschneider <jafo@tummy.com>
* 1.58 release.
diff --git a/memcache.py b/memcache.py
index efb8bff..80c87d6 100644
--- a/memcache.py
+++ b/memcache.py
@@ -553,7 +553,7 @@ class Client(threading.local):
if not server:
return 0
self._statlog(cmd)
- if time is not None and time != 0:
+ if time is not None:
headers = str(time)
else:
headers = None
diff --git a/tests/test_memcache.py b/tests/test_memcache.py
index b5f8884..40b6524 100644
--- a/tests/test_memcache.py
+++ b/tests/test_memcache.py
@@ -51,6 +51,13 @@ class TestMemcache(unittest.TestCase):
self.assertEqual(result, True)
self.assertEqual(self.mc.get("long"), None)
+ @mock.patch.object(_Host, 'send_cmd')
+ @mock.patch.object(_Host, 'readline')
+ def test_touch(self, mock_readline, mock_send_cmd):
+ with captured_stderr():
+ self.mc.touch('key')
+ mock_send_cmd.assert_called_with(b'touch key 0')
+
def test_get_multi(self):
self.check_setget("gm_a_string", "some random string")
self.check_setget("gm_an_integer", 42)