summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChayim <chayim@users.noreply.github.com>2021-09-30 10:54:07 +0300
committerGitHub <noreply@github.com>2021-09-30 10:54:07 +0300
commitcf3973237205d4bcd74d7cf22889ff10aac35539 (patch)
tree5dd9b8fd90c0a211225d85a75921c5cdbf072e5e
parent491c938f9c6ea56fb0b3403be63168e6930709ae (diff)
downloadredis-py-cf3973237205d4bcd74d7cf22889ff10aac35539.tar.gz
Supporting args with MODULE LOAD (#1579)
Part of #1546
-rw-r--r--redis/commands.py6
-rw-r--r--tests/test_commands.py10
2 files changed, 14 insertions, 2 deletions
diff --git a/redis/commands.py b/redis/commands.py
index 5f1f57b..92a9959 100644
--- a/redis/commands.py
+++ b/redis/commands.py
@@ -3081,12 +3081,14 @@ class Commands:
return self.execute_command(command, *pieces, **kwargs)
# MODULE COMMANDS
- def module_load(self, path):
+ def module_load(self, path, *args):
"""
Loads the module from ``path``.
Raises ``ModuleError`` if a module is not found at ``path``.
"""
- return self.execute_command('MODULE LOAD', path)
+ pieces = list(args)
+ pieces.insert(0, path)
+ return self.execute_command('MODULE LOAD', *pieces)
def module_unload(self, name):
"""
diff --git a/tests/test_commands.py b/tests/test_commands.py
index 254aba5..9f0a148 100644
--- a/tests/test_commands.py
+++ b/tests/test_commands.py
@@ -3461,6 +3461,16 @@ class TestRedisCommands:
assert isinstance(res, int)
assert res >= 100
+ @skip_if_server_version_lt('4.0.0')
+ def test_module(self, r):
+ with pytest.raises(redis.exceptions.ModuleError) as excinfo:
+ r.module_load('/some/fake/path')
+ assert "Error loading the extension." in str(excinfo.value)
+
+ with pytest.raises(redis.exceptions.ModuleError) as excinfo:
+ r.module_load('/some/fake/path', 'arg1', 'arg2', 'arg3', 'arg4')
+ assert "Error loading the extension." in str(excinfo.value)
+
class TestBinarySave: