feat(test): expose live_gui_workspace as a separate fixture
This commit is contained in:
+15
-2
@@ -398,10 +398,11 @@ def app_instance() -> Generator[App, None, None]:
|
||||
app.shutdown()
|
||||
|
||||
class _LiveGuiHandle:
|
||||
def __init__(self, process: subprocess.Popen, gui_script: str) -> None:
|
||||
def __init__(self, process: subprocess.Popen, gui_script: str, workspace: Path = None) -> None:
|
||||
"""[SDM: tests/conftest.py:_LiveGuiHandle] [C: tests/conftest.py:live_gui fixture]"""
|
||||
self._process = process
|
||||
self._gui_script = gui_script
|
||||
self._workspace = workspace
|
||||
self._lock = threading.Lock()
|
||||
self._respawn_count = 0
|
||||
|
||||
@@ -427,6 +428,11 @@ class _LiveGuiHandle:
|
||||
"""[M: tests/conftest.py:live_gui fixture]"""
|
||||
return self._gui_script
|
||||
|
||||
@property
|
||||
def workspace(self) -> Path | None:
|
||||
"""[M: tests/conftest.py:live_gui fixture] Absolute path to the live_gui workspace (pytest tmp dir)."""
|
||||
return self._workspace
|
||||
|
||||
def is_alive(self) -> bool:
|
||||
"""Returns True if the subprocess is running."""
|
||||
return self._process is not None and self._process.poll() is None
|
||||
@@ -608,7 +614,7 @@ def live_gui(request, tmp_path_factory) -> Generator["_LiveGuiHandle", None, Non
|
||||
diag.finalize("Live GUI Startup Telemetry", "PASS", "Hook server successfully initialized.")
|
||||
|
||||
try:
|
||||
yield _LiveGuiHandle(process, gui_script)
|
||||
yield _LiveGuiHandle(process, gui_script, temp_workspace)
|
||||
finally:
|
||||
print(f"\n[Fixture] Finally block triggered: Shutting down {gui_script}...")
|
||||
# Reset the GUI state before shutting down
|
||||
@@ -646,3 +652,10 @@ def _check_live_gui_health(request, live_gui) -> Generator[None, None, None]:
|
||||
handle = live_gui
|
||||
handle.ensure_alive()
|
||||
yield
|
||||
|
||||
@pytest.fixture
|
||||
def live_gui_workspace(live_gui) -> Path:
|
||||
"""[SDM: tests/conftest.py:live_gui_workspace] [C: tests/test_rag_phase4_*.py, tests/test_saved_presets_sim.py, etc.]"""
|
||||
handle = live_gui
|
||||
return handle.workspace
|
||||
|
||||
|
||||
Reference in New Issue
Block a user