WIP manage test artifacts in unique folders via global fixtures in conftest
This commit is contained in:
parent
336a82cd24
commit
9207d88176
1 changed files with 30 additions and 3 deletions
|
|
@ -1,3 +1,4 @@
|
|||
from datetime import datetime
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
|
|
@ -12,9 +13,35 @@ def pytest_addoption(parser):
|
|||
|
||||
|
||||
@pytest.fixture
|
||||
def config(request):
|
||||
def dotenv_config(request) -> dict[str, str]:
|
||||
dotenv_path = request.config.getoption("--env_file_path")
|
||||
dotenv_path = Path(dotenv_path)
|
||||
assert dotenv_path.is_file()
|
||||
config = dotenv_values(dotenv_path)
|
||||
return config
|
||||
return dotenv_values(dotenv_path)
|
||||
|
||||
|
||||
@pytest.fixture(scope="session", autouse=True)
|
||||
def session_id() -> str:
|
||||
current_datetime = datetime.now()
|
||||
return current_datetime.strftime("%Y-%m-%d-%H-%M")
|
||||
|
||||
|
||||
@pytest.fixture(scope="session", autouse=True)
|
||||
def TEST_DIR(session_id) -> Path:
|
||||
all_tests_dir = Path("tests")
|
||||
all_tests_dir.mkdir(exist_ok=True)
|
||||
test_dir = all_tests_dir / Path(f"test_{session_id}")
|
||||
test_dir.mkdir()
|
||||
return test_dir
|
||||
|
||||
|
||||
@pytest.fixture(scope="session", autouse=True)
|
||||
def RECORDS(TEST_DIR) -> Path:
|
||||
records = TEST_DIR / Path("records")
|
||||
return records.mkdir()
|
||||
|
||||
|
||||
@pytest.fixture(scope="session", autouse=True)
|
||||
def STATES(TEST_DIR) -> Path:
|
||||
states = TEST_DIR / Path("states")
|
||||
return states.mkdir()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue