diff --git a/redis/commands.py b/redis/commands.py index 42307799de..9dd6ef68f7 100644 --- a/redis/commands.py +++ b/redis/commands.py @@ -1305,9 +1305,9 @@ def lpush(self, name, *values): "Push ``values`` onto the head of the list ``name``" return self.execute_command('LPUSH', name, *values) - def lpushx(self, name, value): + def lpushx(self, name, *values): "Push ``value`` onto the head of the list ``name`` if ``name`` exists" - return self.execute_command('LPUSHX', name, value) + return self.execute_command('LPUSHX', name, *values) def lrange(self, name, start, end): """ diff --git a/tests/test_commands.py b/tests/test_commands.py index d77a01c29a..e2e036e94e 100644 --- a/tests/test_commands.py +++ b/tests/test_commands.py @@ -1263,6 +1263,15 @@ def test_lpushx(self, r): assert r.lpushx('a', '4') == 4 assert r.lrange('a', 0, -1) == [b'4', b'1', b'2', b'3'] + @skip_if_server_version_lt('4.0.0') + def test_lpushx_with_list(self, r): + # now with a list + r.lpush('somekey', 'a') + r.lpush('somekey', 'b') + assert r.lpushx('somekey', 'foo', 'asdasd', 55, 'asdasdas') == 6 + res = r.lrange('somekey', 0, -1) + assert res == [b'asdasdas', b'55', b'asdasd', b'foo', b'b', b'a'] + def test_lrange(self, r): r.rpush('a', '1', '2', '3', '4', '5') assert r.lrange('a', 0, 2) == [b'1', b'2', b'3']