Skip to content

Commit 800720c

Browse files
committed
Merge remote branch 'tabo/master'
2 parents 084d1d6 + c3b3c1b commit 800720c

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

redis/client.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,6 @@ class Redis(object):
153153
Connection and Pipeline derive from this, implementing how
154154
the commands are sent and received to the Redis server
155155
"""
156-
157156
RESPONSE_CALLBACKS = dict_merge(
158157
string_keys_to_dict(
159158
'AUTH DEL EXISTS EXPIRE MOVE MSETNX RENAMENX SADD SISMEMBER SMOVE '
@@ -165,9 +164,14 @@ class Redis(object):
165164
'ZCARD ZREMRANGEBYSCORE',
166165
int
167166
),
167+
string_keys_to_dict(
168+
# these return OK, or int if redis-server is >=1.3.4
169+
'LPUSH RPUSH',
170+
lambda r: isinstance(r, int) and r or r == 'OK'
171+
),
168172
string_keys_to_dict('ZSCORE ZINCRBY', float),
169173
string_keys_to_dict(
170-
'FLUSHALL FLUSHDB LPUSH LSET LTRIM MSET RENAME RPUSH '
174+
'FLUSHALL FLUSHDB LSET LTRIM MSET RENAME '
171175
'SAVE SELECT SET SHUTDOWN',
172176
lambda r: r == 'OK'
173177
),

tests/server_commands.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import redis
22
import unittest
33
import datetime
4+
from distutils.version import StrictVersion
45

56
class ServerCommandsTestCase(unittest.TestCase):
67

@@ -237,8 +238,13 @@ def test_lpush(self):
237238
self.assertRaises(redis.ResponseError, self.client.lpush, 'a', 'a')
238239
del self.client['a']
239240
# real logic
240-
self.assert_(self.client.lpush('a', 'b'))
241-
self.assert_(self.client.lpush('a', 'a'))
241+
version = self.client.info()['redis_version']
242+
if StrictVersion(version) >= StrictVersion('1.3.4'):
243+
self.assertEqual(1, self.client.lpush('a', 'b'))
244+
self.assertEqual(2, self.client.lpush('a', 'a'))
245+
else:
246+
self.assert_(self.client.lpush('a', 'b'))
247+
self.assert_(self.client.lpush('a', 'a'))
242248
self.assertEquals(self.client.lindex('a', 0), 'a')
243249
self.assertEquals(self.client.lindex('a', 1), 'b')
244250

@@ -715,4 +721,4 @@ def test_sort_all_options(self):
715721
self.assertEquals(num, 4)
716722
self.assertEquals(self.client.lrange('sorted', 0, 10),
717723
['vodka', 'milk', 'gin', 'apple juice'])
718-
724+

0 commit comments

Comments
 (0)