rename env_files fixture and turn it into list
This commit is contained in:
parent
e4846fc6bb
commit
b3a7ba876f
1 changed files with 9 additions and 11 deletions
|
|
@ -63,29 +63,27 @@ def DIR(request) -> DirManager:
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(scope="session")
|
@pytest.fixture(scope="session")
|
||||||
def ENV_FILES(DIR: DirManager) -> dict[int, EnvFile]:
|
def env_files(DIR: DirManager) -> list[EnvFile]:
|
||||||
"""Dictionary of all EnvFile instances of the current test run
|
"""list of EnvFile objects created from the given env files"""
|
||||||
|
|
||||||
key: runner_index
|
env_files_dict: dict[int, EnvFile] = dict()
|
||||||
value: EnvFile of the related env file
|
|
||||||
"""
|
|
||||||
|
|
||||||
out: dict[int, EnvFile] = dict()
|
|
||||||
for env_path in DIR.ENV_FILES.glob("*.env"):
|
for env_path in DIR.ENV_FILES.glob("*.env"):
|
||||||
config: dict[str, str] = dotenv_values(env_path) # type: ignore
|
config: dict[str, str] = dotenv_values(env_path) # type: ignore
|
||||||
env_type = config["TYPE"]
|
env_type = config["TYPE"]
|
||||||
result = re.search(r"(\d+)-*", env_path.name)
|
result = re.search(r"(\d+)-*", env_path.name)
|
||||||
assert result
|
assert result
|
||||||
runner_index = int(result[1])
|
runner_index = int(result[1])
|
||||||
out[runner_index] = EnvFile(env_path=env_path, config=config, env_type=env_type)
|
env_files_dict[runner_index] = EnvFile(env_path=env_path, config=config, env_type=env_type)
|
||||||
return out
|
keys = list(env_files_dict.keys())
|
||||||
|
keys.sort()
|
||||||
|
return [env_files_dict[key] for key in keys]
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(scope="session")
|
@pytest.fixture(scope="session")
|
||||||
def env_config(request, ENV_FILES: dict[int, EnvFile]) -> dict[str, str]:
|
def env_config(request, env_files: list[EnvFile]) -> dict[str, str]:
|
||||||
"""Current env_config"""
|
"""Current env_config"""
|
||||||
runner_index = request.config.getoption("--runner_index")
|
runner_index = request.config.getoption("--runner_index")
|
||||||
return ENV_FILES[runner_index].config
|
return env_files[runner_index].config
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(scope="session")
|
@pytest.fixture(scope="session")
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue