from __future__ import annotations from pathlib import Path def test_stop_old_processes_targets_current_repo_only(monkeypatch): import gui.webgui_launcher as launcher inst = launcher.WebGUILauncher.__new__(launcher.WebGUILauncher) logs: list[str] = [] inst.log = logs.append calls: list[list[str]] = [] def _fake_run(cmd, **kwargs): # noqa: ARG001 calls.append(list(cmd)) class _Result: returncode = 0 return _Result() monkeypatch.setattr(launcher.sys, "platform", "win32") monkeypatch.setattr(launcher.subprocess, "run", _fake_run) inst.stop_old_processes() assert calls, "expected stop_old_processes to invoke subprocess.run" ps_cmd = " ".join(calls[0]) expected_root = str(Path(launcher.PROJECT_ROOT)).replace("\\", "\\\\") assert expected_root.lower() in ps_cmd.lower()