From 5ad0df5e61a90a14104c1174cce33743bae766fc Mon Sep 17 00:00:00 2001 From: Itamar Haber Date: Fri, 5 Oct 2018 18:04:53 +0300 Subject: Converts score from string to float Signed-off-by: Itamar Haber --- redis/client.py | 3 ++- tests/test_commands.py | 20 ++++++++++---------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/redis/client.py b/redis/client.py index 535a59b..e5328c5 100755 --- a/redis/client.py +++ b/redis/client.py @@ -385,7 +385,7 @@ class StrictRedis(object): 'SAVE SELECT SHUTDOWN SLAVEOF WATCH UNWATCH', bool_ok ), - string_keys_to_dict('BLPOP BRPOP BZPOPMIN BZPOPMAX', lambda r: r and tuple(r) or None), + string_keys_to_dict('BLPOP BRPOP', lambda r: r and tuple(r) or None), string_keys_to_dict( 'SDIFF SINTER SMEMBERS SUNION', lambda r: r and set(r) or set() @@ -394,6 +394,7 @@ class StrictRedis(object): 'ZPOPMAX ZPOPMIN ZRANGE ZRANGEBYSCORE ZREVRANGE ZREVRANGEBYSCORE', zset_score_pairs ), + string_keys_to_dict('BZPOPMIN BZPOPMAX', lambda r: r and (r[0], r[1], float(r[2])) or None), string_keys_to_dict('ZRANK ZREVRANK', int_or_none), string_keys_to_dict('BGREWRITEAOF BGSAVE', lambda r: True), { diff --git a/tests/test_commands.py b/tests/test_commands.py index 1a5b426..a470cad 100644 --- a/tests/test_commands.py +++ b/tests/test_commands.py @@ -996,13 +996,13 @@ class TestRedisCommands(object): r.delete('c') r.zadd('a', a1=1, a2=2) r.zadd('b', b1=10, b2=20) - assert r.bzpopmax(['b', 'a'], timeout=1) == (b('b'), b('b2'), b('20')) - assert r.bzpopmax(['b', 'a'], timeout=1) == (b('b'), b('b1'), b('10')) - assert r.bzpopmax(['b', 'a'], timeout=1) == (b('a'), b('a2'), b('2')) - assert r.bzpopmax(['b', 'a'], timeout=1) == (b('a'), b('a1'), b('1')) + assert r.bzpopmax(['b', 'a'], timeout=1) == (b('b'), b('b2'), 20) + assert r.bzpopmax(['b', 'a'], timeout=1) == (b('b'), b('b1'), 10) + assert r.bzpopmax(['b', 'a'], timeout=1) == (b('a'), b('a2'), 2) + assert r.bzpopmax(['b', 'a'], timeout=1) == (b('a'), b('a1'), 1) assert r.bzpopmax(['b', 'a'], timeout=1) is None r.zadd('c', c1=100) - assert r.bzpopmax('c', timeout=1) == (b('c'), b('c1'), b('100')) + assert r.bzpopmax('c', timeout=1) == (b('c'), b('c1'), 100) @skip_if_server_version_lt('4.9.0') def test_bzpopmin(self, r): @@ -1011,13 +1011,13 @@ class TestRedisCommands(object): r.delete('c') r.zadd('a', a1=1, a2=2) r.zadd('b', b1=10, b2=20) - assert r.bzpopmin(['b', 'a'], timeout=1) == (b('b'), b('b1'), b('10')) - assert r.bzpopmin(['b', 'a'], timeout=1) == (b('b'), b('b2'), b('20')) - assert r.bzpopmin(['b', 'a'], timeout=1) == (b('a'), b('a1'), b('1')) - assert r.bzpopmin(['b', 'a'], timeout=1) == (b('a'), b('a2'), b('2')) + assert r.bzpopmin(['b', 'a'], timeout=1) == (b('b'), b('b1'), 10) + assert r.bzpopmin(['b', 'a'], timeout=1) == (b('b'), b('b2'), 20) + assert r.bzpopmin(['b', 'a'], timeout=1) == (b('a'), b('a1'), 1) + assert r.bzpopmin(['b', 'a'], timeout=1) == (b('a'), b('a2'), 2) assert r.bzpopmin(['b', 'a'], timeout=1) is None r.zadd('c', c1=100) - assert r.bzpopmin('c', timeout=1) == (b('c'), b('c1'), b('100')) + assert r.bzpopmin('c', timeout=1) == (b('c'), b('c1'), 100) def test_zrange(self, r): r.zadd('a', a1=1, a2=2, a3=3) -- cgit v1.2.1