Private
Public Access
fix(test): per-run workspace under tests/artifacts/ (replaces tmp_path_factory)
This commit is contained in:
+8
-4
@@ -11,7 +11,12 @@ import shutil
|
|||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Generator, Any
|
from typing import Generator, Any
|
||||||
from unittest.mock import patch
|
from unittest.mock import patch
|
||||||
|
project_root = os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))
|
||||||
|
if project_root not in sys.path:
|
||||||
|
sys.path.insert(0, project_root)
|
||||||
|
|
||||||
|
_RUN_ID = datetime.datetime.now().strftime("%Y%m%d_%H%M%S")
|
||||||
|
_RUN_WORKSPACE = Path(f"tests/artifacts/live_gui_workspace_{_RUN_ID}")
|
||||||
thirdparty_dir = os.path.join(os.path.dirname(__file__), "..", "thirdparty")
|
thirdparty_dir = os.path.join(os.path.dirname(__file__), "..", "thirdparty")
|
||||||
if thirdparty_dir not in sys.path:
|
if thirdparty_dir not in sys.path:
|
||||||
sys.path.insert(0, thirdparty_dir)
|
sys.path.insert(0, thirdparty_dir)
|
||||||
@@ -448,9 +453,8 @@ class _LiveGuiHandle:
|
|||||||
"""[M: tests/conftest.py:_LiveGuiHandle.ensure_alive]"""
|
"""[M: tests/conftest.py:_LiveGuiHandle.ensure_alive]"""
|
||||||
return self._respawn_count
|
return self._respawn_count
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(scope="session")
|
@pytest.fixture(scope="session")
|
||||||
def live_gui(request, tmp_path_factory) -> Generator["_LiveGuiHandle", None, None]:
|
def live_gui(request) -> Generator["_LiveGuiHandle", None, None]:
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
@@ -461,8 +465,8 @@ def live_gui(request, tmp_path_factory) -> Generator["_LiveGuiHandle", None, Non
|
|||||||
diag = VerificationLogger("live_gui_startup", "live_gui_diag")
|
diag = VerificationLogger("live_gui_startup", "live_gui_diag")
|
||||||
diag.log_state("GUI Script", "N/A", "gui_2.py")
|
diag.log_state("GUI Script", "N/A", "gui_2.py")
|
||||||
|
|
||||||
# 1. Create a isolated workspace for the live GUI (in pytest tmp dir, not project tree)
|
# 1. Create a isolated workspace for the live GUI (per-run timestamped folder under tests/artifacts/)
|
||||||
temp_workspace = tmp_path_factory.mktemp("live_gui_workspace")
|
temp_workspace = _RUN_WORKSPACE
|
||||||
if temp_workspace.exists():
|
if temp_workspace.exists():
|
||||||
for _ in range(5):
|
for _ in range(5):
|
||||||
try:
|
try:
|
||||||
|
|||||||
Reference in New Issue
Block a user