From cf3973237205d4bcd74d7cf22889ff10aac35539 Mon Sep 17 00:00:00 2001 From: Chayim Date: Thu, 30 Sep 2021 10:54:07 +0300 Subject: Supporting args with MODULE LOAD (#1579) Part of #1546 --- redis/commands.py | 6 ++++-- tests/test_commands.py | 10 ++++++++++ 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: -- cgit v1.2.1