Download tests/test_atspi_guard.py from hkblockchaintechnology/tiny-computer-agent: direct link, hf CLI and curl.
- Browser
- Download file 1.79 kB
-
https://huggingface.co/hkblockchaintechnology/tiny-computer-agent/resolve/main/tests/test_atspi_guard.py
- Command line
-
hf download hf://hkblockchaintechnology/tiny-computer-agent/tests/test_atspi_guard.py
-
curl -L -o test_atspi_guard.py https://huggingface.co/hkblockchaintechnology/tiny-computer-agent/resolve/main/tests/test_atspi_guard.py
1.79 kB
| """The AT-SPI guard must actually skip when there is no typelib. | |
| Same bug, one layer down from the OCR guard: `make_detector("atspi")` correctly | |
| raises without PyGObject, so two tests failed on a machine that has no AT-SPI | |
| reader - and a failing test reads like a harness defect rather than a missing | |
| system package. The guard now asks the backend that needs the typelib, and here | |
| is the proof that it skips, passes, and asks for the right thing. | |
| """ | |
| import pytest | |
| from conftest import require_atspi | |
| import tiny_computer_agent.accessibility as accessibility | |
| def test_the_guard_skips_when_the_typelib_is_missing(monkeypatch): | |
| monkeypatch.setattr(accessibility, "accessibility_available", | |
| lambda name="atspi": (False, "simulated: no PyGObject")) | |
| with pytest.raises(pytest.skip.Exception): | |
| require_atspi() | |
| def test_the_guard_passes_when_the_reader_can_be_built(monkeypatch): | |
| monkeypatch.setattr(accessibility, "accessibility_available", | |
| lambda name="atspi": (True, "simulated: AT-SPI reader ready")) | |
| require_atspi() # must not raise | |
| def test_the_guard_asks_for_atspi_and_not_a_name_that_always_resolves(monkeypatch): | |
| asked = [] | |
| def record(name="atspi"): | |
| asked.append(name) | |
| return True, "recorded" | |
| monkeypatch.setattr(accessibility, "accessibility_available", record) | |
| require_atspi() | |
| assert asked == ["atspi"] | |
| def test_uia_is_reported_unavailable_on_linux_and_that_is_not_a_failure(): | |
| """Why the Windows test had to be split rather than guarded as a whole.""" | |
| available, detail = accessibility.accessibility_available("uia") | |
| assert available is False, "UI Automation is Windows-only" | |
| assert detail, "an unavailable backend still has to say why" | |