Permalink
Browse files

fixed negative indexes in zrange

  • Loading branch information...
Oleg Baranovskiy
Oleg Baranovskiy committed Apr 3, 2014
1 parent 0ff696b commit b8850f23b9cf330329e1285ad36b56b1c159f1ca
Showing with 15 additions and 1 deletion.
  1. +2 −0 .gitignore
  2. +1 −1 asyncio_redis/protocol.py
  3. +12 −0 tests.py
View
@@ -0,0 +1,2 @@
*.py[cod]
__pycache__
@@ -770,7 +770,7 @@ def data_received(self, data):
def _encode_int(self, value:int) -> bytes:
""" Encodes an integer to bytes. (always ascii) """
if value < 1000: # For small values, take pre-encoded string.
if 0 < value < 1000: # For small values, take pre-encoded string.
return _SMALL_INTS[value]
else:
return str(value).encode('ascii')
View
@@ -1021,6 +1021,18 @@ def test_zset(self, transport, protocol):
{'key2': 5.0},
{'key3': 5.5} ])
# Test zrange with negative indexes
result = yield from protocol.zrange('myzset', -2, -1)
self.assertIsInstance(result, ZRangeReply)
for f in result:
d = yield from f
self.assertIn(d, [
{'key2': 5.0},
{'key3': 5.5} ])
# Test zrangebyscore
result = yield from protocol.zrangebyscore('myzset')
self.assertEqual((yield from result.asdict()),

0 comments on commit b8850f2

Please sign in to comment.