Skip to content

Commit

Permalink
Move splitting config to list to config creation
Browse files Browse the repository at this point in the history
  • Loading branch information
fizyk committed Jun 5, 2024
1 parent 6ba4372 commit 8865e3a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
10 changes: 7 additions & 3 deletions pytest_redis/config.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Config loading helpers."""

from typing import Any, Optional, TypedDict
from typing import Any, Optional, TypedDict, List

from _pytest.fixtures import FixtureRequest

Expand All @@ -22,7 +22,7 @@ class RedisConfigType(TypedDict):
syslog: bool
decode: bool
datadir: str
modules: Optional[str]
modules: List[str]


def get_config(request: FixtureRequest) -> RedisConfigType:
Expand All @@ -33,6 +33,10 @@ def get_conf_option(option: str) -> Any:
return request.config.getoption(option_name) or request.config.getini(option_name)

port = get_conf_option("port")
if (modules := get_conf_option("modules")) is not None:
modules = modules.split(",")
else:
modules = []
config: RedisConfigType = {
"host": get_conf_option("host"),
"port": int(port) if port else None,
Expand All @@ -48,6 +52,6 @@ def get_conf_option(option: str) -> Any:
"syslog": bool(get_conf_option("syslog")),
"decode": bool(get_conf_option("decode")),
"datadir": get_conf_option("datadir"),
"modules": get_conf_option("modules"),
"modules": modules,
}
return config
7 changes: 1 addition & 6 deletions pytest_redis/factories/proc.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,7 @@ def redis_proc_fixture(
else:
redis_datadir = tmp_path_factory.mktemp(f"pytest-redis-{request.fixturename}")

if modules:
redis_modules = modules
elif config["modules"]:
redis_modules = config["modules"].split(",")
else:
redis_modules = []
redis_modules = modules or config["modules"]

redis_port = get_port(port) or get_port(config["port"])
assert redis_port
Expand Down

0 comments on commit 8865e3a

Please sign in to comment.