add asserts to pytest command line arguments

This commit is contained in:
Daniel 2023-11-24 12:22:45 +01:00
parent 23b81317c5
commit befad97cc1

View file

@ -41,14 +41,17 @@ def pytest_addoption(parser):
@pytest.fixture(scope="session", autouse=True)
def dirmanager(request) -> DirManager:
tests_dir = request.config.getoption("--tests_dir")
assert tests_dir is not None, "required pytest command line argument not given"
tests_dir = Path(tests_dir)
session_id = request.config.getoption("--session_id")
assert session_id is not None, "required pytest command line argument not given"
return DirManager(tests_dir=tests_dir, session_id=session_id)
@pytest.fixture(scope="session", autouse=True)
def dotenv_config(request) -> dict[str, str]:
dotenv_path = request.config.getoption("--env_file")
assert dotenv_path is not None, "required pytest command line argument not given"
dotenv_path = Path(dotenv_path)
assert dotenv_path.is_file()
return dotenv_values(dotenv_path)