Merge pull request #619 from foxx/patch-1

Fixes #613
This commit is contained in:
Selwin Ong 2015-11-28 11:55:51 +07:00
commit 961e443611
2 changed files with 3 additions and 5 deletions

View File

@ -1,2 +1,2 @@
redis>=2.7
click>=3.0.0
click<6.0

View File

@ -22,9 +22,6 @@ PATCHED_METHODS = ['_setex', '_lrem', '_zadd', '_pipeline', '_ttl']
def patch_connection(connection):
if not isinstance(connection, StrictRedis):
raise ValueError('A StrictRedis or Redis connection is required.')
# Don't patch already patches objects
if all([hasattr(connection, attr) for attr in PATCHED_METHODS]):
return connection
@ -38,7 +35,8 @@ def patch_connection(connection):
if hasattr(connection, 'pttl'):
connection._pttl = fix_return_type(partial(StrictRedis.pttl, connection))
elif isinstance(connection, StrictRedis):
# add support for mock redis objects
elif hasattr(connection, 'setex'):
connection._setex = connection.setex
connection._lrem = connection.lrem
connection._zadd = connection.zadd