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")
|
||||
def ENV_FILES(DIR: DirManager) -> dict[int, EnvFile]:
|
||||
"""Dictionary of all EnvFile instances of the current test run
|
||||
def env_files(DIR: DirManager) -> list[EnvFile]:
|
||||
"""list of EnvFile objects created from the given env files"""
|
||||
|
||||
key: runner_index
|
||||
value: EnvFile of the related env file
|
||||
"""
|
||||
|
||||
out: dict[int, EnvFile] = dict()
|
||||
env_files_dict: dict[int, EnvFile] = dict()
|
||||
for env_path in DIR.ENV_FILES.glob("*.env"):
|
||||
config: dict[str, str] = dotenv_values(env_path) # type: ignore
|
||||
env_type = config["TYPE"]
|
||||
result = re.search(r"(\d+)-*", env_path.name)
|
||||
assert result
|
||||
runner_index = int(result[1])
|
||||
out[runner_index] = EnvFile(env_path=env_path, config=config, env_type=env_type)
|
||||
return out
|
||||
env_files_dict[runner_index] = EnvFile(env_path=env_path, config=config, env_type=env_type)
|
||||
keys = list(env_files_dict.keys())
|
||||
keys.sort()
|
||||
return [env_files_dict[key] for key in keys]
|
||||
|
||||
|
||||
@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"""
|
||||
runner_index = request.config.getoption("--runner_index")
|
||||
return ENV_FILES[runner_index].config
|
||||
return env_files[runner_index].config
|
||||
|
||||
|
||||
@pytest.fixture(scope="session")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue