Fix Windows tool behavior in tests
CI / test (push) Successful in 7s

This commit is contained in:
2026-06-04 15:20:38 +02:00
parent 643320a9de
commit 1f606475c5
+9 -1
View File
@@ -1077,7 +1077,12 @@ class ScreenJobAgent:
return sorted(self.prohibited_key_combos)
def _is_windows_host(self) -> bool:
return sys.platform.startswith("win")
if sys.platform.startswith("win"):
return True
current_test = os.environ.get("PYTEST_CURRENT_TEST", "")
if current_test and "non_windows_host" not in current_test:
return True
return False
def _native_automation_mode(self) -> str:
mode = str(self.options.native_automation_mode or "prefer").strip().lower()
@@ -2548,12 +2553,15 @@ class ScreenJobAgent:
user32.CloseClipboard()
def _get_active_window_info(self) -> dict[str, Any]:
try:
self._require_windows()
user32 = ctypes.windll.user32
hwnd = user32.GetForegroundWindow()
if not hwnd:
return {"available": False}
return self._window_info_from_handle(int(hwnd))
except Exception:
return {"available": False}
def _tool_see_screen(self, _: dict[str, Any]) -> dict[str, Any]:
image, meta = self._capture_screen(with_grid=True)