summaryrefslogtreecommitdiff
path: root/tests/server_commands.py
diff options
context:
space:
mode:
authorAndy McCurdy <andy@andymccurdy.com>2011-07-11 00:44:16 -0700
committerAndy McCurdy <andy@andymccurdy.com>2011-07-11 00:44:16 -0700
commitbde615669c8c0158b9ba9e38129cf67d9f474d81 (patch)
treec8e567df2b049d331156fbae856e7fe9ca2eff53 /tests/server_commands.py
parent24b0f17a80b51ed2d7f7e1ca139428f27bf642c9 (diff)
downloadredis-py-bde615669c8c0158b9ba9e38129cf67d9f474d81.tar.gz
Allow a custom callable to be passed to commands whose responses are parsed with zset_score_pairs indicating how to cast the score value. Defaults to a float. Fix for #155
Diffstat (limited to 'tests/server_commands.py')
-rw-r--r--tests/server_commands.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/tests/server_commands.py b/tests/server_commands.py
index f3fd524..7faa081 100644
--- a/tests/server_commands.py
+++ b/tests/server_commands.py
@@ -791,7 +791,6 @@ class ServerCommandsTestCase(unittest.TestCase):
[('a3', 20), ('a1', 23)]
)
-
def test_zrange(self):
# key is not a zset
self.client['a'] = 'a'
@@ -805,10 +804,13 @@ class ServerCommandsTestCase(unittest.TestCase):
[('a1', 1.0), ('a2', 2.0)])
self.assertEquals(self.client.zrange('a', 1, 2, withscores=True),
[('a2', 2.0), ('a3', 3.0)])
+ # test a custom score casting function returns the correct value
+ self.assertEquals(
+ self.client.zrange('a', 0, 1, withscores=True, score_cast_func=int),
+ [('a1', 1), ('a2', 2)])
# a non existant key should return empty list
self.assertEquals(self.client.zrange('b', 0, 1, withscores=True), [])
-
def test_zrangebyscore(self):
# key is not a zset
self.client['a'] = 'a'