Skip to content

Commit 117e159

Browse files
committed
Disable scananddump when hiredis
1 parent 15bd5d0 commit 117e159

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

redis/commands/bf/commands.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
from redis.client import NEVER_DECODE
2+
from redis.exceptions import ModuleError
3+
from redis.utils import HIREDIS_AVAILABLE
4+
15
BF_RESERVE = "BF.RESERVE"
26
BF_ADD = "BF.ADD"
37
BF_MADD = "BF.MADD"
@@ -133,7 +137,8 @@ def scandump(self, key, iter):
133137
This command will return successive (iter, data) pairs until (0, NULL) to indicate completion.
134138
For more information see `BF.SCANDUMP <https://oss.redis.com/redisbloom/master/Bloom_Commands/#bfscandump>`_.
135139
""" # noqa
136-
from redis.client import NEVER_DECODE
140+
if HIREDIS_AVAILABLE:
141+
raise ModuleError("This command cannot be used when hiredis is available.")
137142

138143
params = [key, iter]
139144
options = {}

tests/test_bloom.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import pytest
22

33
import redis.commands.bf
4-
from redis.exceptions import RedisError
4+
from redis.exceptions import ModuleError, RedisError
5+
from redis.utils import HIREDIS_AVAILABLE
56

67

78
def intlist(obj):
@@ -85,6 +86,11 @@ def do_verify():
8586

8687
do_verify()
8788
cmds = []
89+
if HIREDIS_AVAILABLE:
90+
with pytest.raises(ModuleError):
91+
cur = client.bf().scandump("myBloom", 0)
92+
return
93+
8894
cur = client.bf().scandump("myBloom", 0)
8995
first = cur[0]
9096
cmds.append(cur)

0 commit comments

Comments
 (0)