Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix issue #656: add 'modules' keyword arg to load Redis extension mod… #657

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions pytest_redis/executor/process.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ def __init__(
syslog_enabled: bool = False,
appendonly: str = "no",
datadir: Optional[Path] = None,
modules: Optional[list[str]] = None,
) -> None: # pylint:disable=too-many-locals
"""Init method of a RedisExecutor.

Expand All @@ -79,6 +80,7 @@ def __init__(
to the system logger
:param datadir: location where all the process files will be located
:param appendonly:
:param modules: list of paths of Redis extension modules to load
"""
if not datadir:
datadir = Path(gettempdir())
Expand Down Expand Up @@ -142,6 +144,9 @@ def __init__(
else:
command.extend([f"--save {save}"])

if modules:
command.extend([f"--loadmodule {module_path}" for module_path in modules])

super().__init__(command, host, port, timeout=startup_timeout)

@classmethod
Expand Down
3 changes: 3 additions & 0 deletions pytest_redis/factories/proc.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ def redis_proc(
syslog: Optional[bool] = None,
loglevel: Optional[str] = None,
datadir: Optional[str] = None,
modules: Optional[list[str]] = None,
) -> Callable[[FixtureRequest, TempPathFactory], Generator[RedisExecutor, None, None]]:
"""Fixture factory for pytest-redis.

Expand All @@ -62,6 +63,7 @@ def redis_proc(
:param datadir: Path for redis data files, including the unix domain socket.
If this is not configured, then a temporary directory is created and used
instead.
:param modules: list of paths of Redis extension modules to load
:returns: function which makes a redis process
"""

Expand Down Expand Up @@ -109,6 +111,7 @@ def redis_proc_fixture(
password=password or config["password"],
startup_timeout=60,
datadir=redis_datadir,
modules=modules,
)
with redis_executor:
yield redis_executor
Expand Down
Loading