File size: 2,230 Bytes
d0b825c | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 | """The things only real Windows can verify.
Skipped everywhere else, so the suite stays green on Linux while these stay honest:
they are the reason `display_available()` and the capture backend are more than an
assertion about a code path. The `windows-latest` CI job runs them, and so does a
Windows machine with `-m pytest tests/test_windows_platform.py`.
"""
import os
import platform
import pytest
WINDOWS = platform.system() == "Windows"
pytestmark = pytest.mark.skipif(not WINDOWS, reason="needs real Windows")
def test_display_available_says_so_on_windows():
from tiny_computer_agent import display_available
ok, detail = display_available()
assert ok is True
assert "Windows" in detail
def test_capture_returns_the_real_screen():
from tiny_computer_agent import GrabScreen
observation = GrabScreen(monitor=1).capture()
frame = observation.frame
assert frame.width > 100 and frame.height > 100
sampled = {pixel for row in list(frame.resize((8, 8)).getdata()) for pixel in [row]}
assert len(sampled) > 1, "the screenshot came back as one flat colour"
def test_a_detector_that_needs_nothing_still_indexes_the_screen():
from tiny_computer_agent import GrabScreen, make_detector
frame = GrabScreen(monitor=1).capture().frame
assert len(make_detector("grid").detect(frame)) == 96
def test_ui_automation_is_reported_truthfully():
from tiny_computer_agent import accessibility_available
ok, detail = accessibility_available("uia")
assert isinstance(ok, bool) and detail
def test_the_doctor_reports_a_ready_windows_desktop():
from tiny_computer_agent import run_checks
checks = {check.name: check for check in run_checks(brain="planner", detector="grid")}
assert checks["display server"].ok is True
assert checks["pillow"].ok is True
@pytest.mark.skipif(os.environ.get("TINY_COMPUTER_AGENT_LIVE_TEST") != "1",
reason="moves the real mouse: opt in, and use a throwaway desktop")
def test_the_real_mouse_goes_where_it_is_asked():
pyautogui = pytest.importorskip("pyautogui")
pyautogui.moveTo(120, 140)
assert abs(pyautogui.position().x - 120) <= 2
assert abs(pyautogui.position().y - 140) <= 2
|