Skip to content

Commit 97f86f9

Browse files
committed
fix pr comment
1 parent a614caf commit 97f86f9

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

redis/commands/core.py

+9-2
Original file line numberDiff line numberDiff line change
@@ -3261,7 +3261,8 @@ def bzmpop(
32613261
timeout: float,
32623262
num_keys: int,
32633263
keys: List[str],
3264-
min_max: str,
3264+
min: Optional[bool] = False,
3265+
max: Optional[bool] = False,
32653266
count: Optional[int] = 1,
32663267
) -> Optional[list]:
32673268
"""
@@ -3276,7 +3277,13 @@ def bzmpop(
32763277
32773278
For more information check https://redis.io/commands/bzmpop
32783279
"""
3279-
args = [timeout, num_keys] + keys + [min_max]
3280+
args = [timeout, num_keys, *keys]
3281+
if (min and max) or (not min and not max):
3282+
raise DataError
3283+
elif min:
3284+
args.append("MIN")
3285+
else:
3286+
args.append("MAX")
32803287
if count != 1:
32813288
args.extend(["COUNT", count])
32823289

tests/test_commands.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -2063,12 +2063,12 @@ def test_bzpopmin(self, r):
20632063
def test_bzmpop(self, unstable_r):
20642064
unstable_r.zadd("a", {"a1": 1, "a2": 2, "a3": 3})
20652065
res = [b"a", [[b"a1", b"1"], [b"a2", b"2"]]]
2066-
assert unstable_r.bzmpop(1, "2", ["b", "a"], "MIN", count=2) == res
2067-
with pytest.raises(TypeError):
2066+
assert unstable_r.bzmpop(1, "2", ["b", "a"], min=True, count=2) == res
2067+
with pytest.raises(redis.DataError):
20682068
unstable_r.bzmpop(1, "2", ["b", "a"], count=2)
20692069
unstable_r.zadd("b", {"b1": 10, "ab": 9, "b3": 8})
2070-
assert unstable_r.bzmpop(0, "2", ["b", "a"], "MAX") == [b"b", [[b"b1", b"10"]]]
2071-
assert unstable_r.bzmpop(1, "2", ["foo", "bar"], "MAX") is None
2070+
assert unstable_r.bzmpop(0, "2", ["b", "a"], max=True) == [b"b", [[b"b1", b"10"]]]
2071+
assert unstable_r.bzmpop(1, "2", ["foo", "bar"], max=True) is None
20722072

20732073
def test_zrange(self, r):
20742074
r.zadd("a", {"a1": 1, "a2": 2, "a3": 3})

0 commit comments

Comments
 (0)