Skip to content

Commit 5ac97a1

Browse files
authored
fix lpos bug
1 parent e4ac9e2 commit 5ac97a1

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

mockredis/client.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -655,7 +655,10 @@ def lrange(self, key, start, stop):
655655

656656
def lpos(self, name, value):
657657
"""Emulate lpos. (naive implementation)"""
658-
return list(self.lrange(name, 0, -1)).index(value)
658+
values = list(self.lrange(name, 0, -1))
659+
if name not in values:
660+
return None
661+
return value.index(value)
659662

660663
def lindex(self, key, index):
661664
"""Emulate lindex."""

0 commit comments

Comments
 (0)