Skip to content

Commit b13a323

Browse files
author
Jesse Myers
committed
Merge in fix for Issue #75
Conflicts: mockredis/client.py mockredis/tests/test_hash.py
2 parents a505a32 + 22a8d2c commit b13a323

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

mockredis/client.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,7 @@ def pttl(self, key):
211211
return long(-2) if self.strict else None
212212
if key not in self.timeouts:
213213
# as of redis 2.8, -1 is returned if the key is persistent
214+
# redis-py returns None; command docs say -1
214215
return long(-1) if self.strict else None
215216

216217
time_to_live = get_total_milliseconds(self.timeouts[key] - self.clock.now())
@@ -472,20 +473,20 @@ def hset(self, hashkey, attribute, value):
472473

473474
redis_hash = self._get_hash(hashkey, 'HSET', create=True)
474475
attribute = self._encode(attribute)
475-
was_present = attribute in redis_hash
476+
attribute_present = attribute in redis_hash
476477
redis_hash[attribute] = self._encode(value)
477-
return 0 if was_present else 1
478+
return long(0) if attribute_present else long(1)
478479

479480
def hsetnx(self, hashkey, attribute, value):
480481
"""Emulate hsetnx."""
481482

482483
redis_hash = self._get_hash(hashkey, 'HSETNX', create=True)
483484
attribute = self._encode(attribute)
484485
if attribute in redis_hash:
485-
return 0
486+
return long(0)
486487
else:
487488
redis_hash[attribute] = self._encode(value)
488-
return 1
489+
return long(1)
489490

490491
def hincrby(self, hashkey, attribute, increment=1):
491492
"""Emulate hincrby."""

mockredis/tests/test_hash.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ def test_hget(self):
5252

5353
def test_hset_integral(self):
5454
hashkey = "hash"
55-
self.redis.hset(hashkey, 1, 2)
55+
eq_(1, self.redis.hset(hashkey, 1, 2))
5656
eq_(b"2", self.redis.hget(hashkey, 1))
5757
eq_(b"2", self.redis.hget(hashkey, "1"))
5858

0 commit comments

Comments
 (0)