An AI Agent that interacts with Windows OS at GUI level.
Python
Fix 4 CI test failures: screen size, OpenAI key, pytest-asyncio
jeomon2d16c7888bfc
diff --git a/pyproject.toml b/pyproject.tomlindex e0742aa..ce183ec 100644--- a/pyproject.toml+++ b/pyproject.toml@@ -69,6 +69,7 @@ windows-use = "windows_use.cli.__main__:main"[project.optional-dependencies]dev = ["pytest>=8.4.1",+ "pytest-asyncio>=0.24.0","ruff>=0.12.1",]speech = [@@ -84,6 +85,9 @@ build-backend = "hatchling.build"[tool.hatch.build]packages = ["windows_use"]+[tool.pytest.ini_options]+asyncio_mode = "auto"+[tool.ruff]line-length = 100target-version = "py310"diff --git a/tests/unit/desktop/test_desktop_init.py b/tests/unit/desktop/test_desktop_init.pyindex 22025b5..6c340e2 100644--- a/tests/unit/desktop/test_desktop_init.py+++ b/tests/unit/desktop/test_desktop_init.py@@ -24,7 +24,11 @@ class TestDesktopService:def test_init(self, desktop):assert desktop.desktop_state is None- assert desktop.get_screen_size().width == 1920+ with patch(+ "windows_use.agent.desktop.service.uia.GetVirtualScreenSize",+ return_value=(1920, 1080),+ ):+ assert desktop.get_screen_size().width == 1920@patch("windows_use.agent.desktop.service.win32gui.EnumWindows")@patch("windows_use.agent.desktop.service.win32gui.IsWindowVisible")diff --git a/tests/unit/test_llm_events.py b/tests/unit/test_llm_events.pyindex a588c95..d2d81fe 100644--- a/tests/unit/test_llm_events.py+++ b/tests/unit/test_llm_events.py@@ -1,10 +1,17 @@-from unittest.mock import MagicMock+from unittest.mock import MagicMock, patchfrom windows_use.messages import HumanMessagefrom windows_use.providers.events import LLMStreamEvent, LLMStreamEventTypefrom windows_use.providers.openai.llm import ChatOpenAI+def make_provider(model: str) -> ChatOpenAI:+ with patch("windows_use.providers.openai.llm.OpenAI"), patch(+ "windows_use.providers.openai.llm.AsyncOpenAI"+ ):+ return ChatOpenAI(model=model, api_key="test-key")++def create_mock_chunk(content=None, tool_calls=None, reasoning=None):delta = MagicMock()delta.content = content@@ -32,7 +39,7 @@ def create_mock_chunk(content=None, tool_calls=None, reasoning=None):def test_stream_text_only():- provider = ChatOpenAI(model="gpt-4o")+ provider = make_provider("gpt-4o")mock_chunks = [create_mock_chunk(content="Hello"),@@ -53,7 +60,7 @@ def test_stream_text_only():def test_stream_tool_only():- provider = ChatOpenAI(model="gpt-4o")+ provider = make_provider("gpt-4o")mock_chunks = [create_mock_chunk(@@ -76,7 +83,7 @@ def test_stream_tool_only():def test_stream_thinking_then_text():- provider = ChatOpenAI(model="o3-mini")+ provider = make_provider("o3-mini")mock_chunks = [create_mock_chunk(reasoning="Thinking"),diff --git a/tests/unit/test_openai_events.py b/tests/unit/test_openai_events.pyindex 3fd704c..0127087 100644--- a/tests/unit/test_openai_events.py+++ b/tests/unit/test_openai_events.py@@ -1,4 +1,5 @@import asyncio+from unittest.mock import patchimport pytestfrom pydantic import BaseModel@@ -9,6 +10,13 @@ from windows_use.providers.openai.llm import ChatOpenAIfrom windows_use.tools import Tool+def make_llm(**kwargs) -> ChatOpenAI:+ with patch("windows_use.providers.openai.llm.OpenAI"), patch(+ "windows_use.providers.openai.llm.AsyncOpenAI"+ ):+ return ChatOpenAI(api_key="test-key", **kwargs)++class DummyToolModel(BaseModel):dummy: str@@ -19,7 +27,7 @@ dummy_tool = Tool(name="dummy_tool", description="A dummy tool for testing", mod@pytest.mark.asyncioasync def test_streaming_text():print("=== Testing Streaming Text ===")- llm = ChatOpenAI(model="gpt-4o-mini", max_retries=1)+ llm = make_llm(model="gpt-4o-mini", max_retries=1)# MOCK OPENAI STREAMfrom unittest.mock import MagicMock@@ -69,7 +77,7 @@ async def test_streaming_text():@pytest.mark.asyncioasync def test_streaming_tools():print("\n=== Testing Streaming Tools ===")- llm = ChatOpenAI(model="gpt-4o-mini", max_retries=1)+ llm = make_llm(model="gpt-4o-mini", max_retries=1)# MOCK OPENAI STREAMfrom unittest.mock import MagicMock@@ -128,7 +136,7 @@ async def test_streaming_tools():@pytest.mark.asyncioasync def test_invoke_text():print("\n=== Testing Invoke Text ===")- llm = ChatOpenAI(model="gpt-4o-mini", max_retries=1)+ llm = make_llm(model="gpt-4o-mini", max_retries=1)# MOCK OPENAI INVOKEfrom unittest.mock import MagicMock@@ -171,7 +179,7 @@ async def test_invoke_text():@pytest.mark.asyncioasync def test_ainvoke_tools():print("\n=== Testing Ainvoke Tools ===")- llm = ChatOpenAI(model="gpt-4o-mini", max_retries=1)+ llm = make_llm(model="gpt-4o-mini", max_retries=1)# MOCK OPENAI AINVOKEfrom unittest.mock import MagicMockdiff --git a/uv.lock b/uv.lockindex 49098d4..80e80ea 100644--- a/uv.lock+++ b/uv.lock@@ -327,6 +327,15 @@ wheels = [{ url = "https://files.pythonhosted.org/packages/df/73/b6e24bd22e6720ca8ee9a85a0c4a2971af8497d8f3193fa05390cbd46e09/backoff-2.2.1-py3-none-any.whl", hash = "sha256:63579f9a0628e06278f7e47b7d7d5b6ce20dc65c5e96a6f3ca99a6adca0396e8", size = 15148, upload-time = "2022-10-05T19:19:30.546Z" },]+[[package]]+name = "backports-asyncio-runner"+version = "1.2.0"+source = { registry = "https://pypi.org/simple" }+sdist = { url = "https://files.pythonhosted.org/packages/8e/ff/70dca7d7cb1cbc0edb2c6cc0c38b65cba36cccc491eca64cabd5fe7f8670/backports_asyncio_runner-1.2.0.tar.gz", hash = "sha256:a5aa7b2b7d8f8bfcaa2b57313f70792df84e32a2a746f585213373f900b42162", size = 69893, upload-time = "2025-07-02T02:27:15.685Z" }+wheels = [+ { url = "https://files.pythonhosted.org/packages/a0/59/76ab57e3fe74484f48a53f8e337171b4a2349e506eabe136d7e01d059086/backports_asyncio_runner-1.2.0-py3-none-any.whl", hash = "sha256:0da0a936a8aeb554eccb426dc55af3ba63bcdc69fa1a600b5bb305413a4477b5", size = 12313, upload-time = "2025-07-02T02:27:14.263Z" },+]+[[package]]name = "backports-tarfile"version = "1.2.0"@@ -3109,6 +3118,20 @@ wheels = [{ url = "https://files.pythonhosted.org/packages/a8/a4/20da314d277121d6534b3a980b29035dcd51e6744bd79075a6ce8fa4eb8d/pytest-8.4.2-py3-none-any.whl", hash = "sha256:872f880de3fc3a5bdc88a11b39c9710c3497a547cfa9320bc3c5e62fbf272e79", size = 365750, upload-time = "2025-09-04T14:34:20.226Z" },]+[[package]]+name = "pytest-asyncio"+version = "1.3.0"+source = { registry = "https://pypi.org/simple" }+dependencies = [+ { name = "backports-asyncio-runner", marker = "python_full_version < '3.11'" },+ { name = "pytest" },+ { name = "typing-extensions", marker = "python_full_version < '3.13'" },+]+sdist = { url = "https://files.pythonhosted.org/packages/90/2c/8af215c0f776415f3590cac4f9086ccefd6fd463befeae41cd4d3f193e5a/pytest_asyncio-1.3.0.tar.gz", hash = "sha256:d7f52f36d231b80ee124cd216ffb19369aa168fc10095013c6b014a34d3ee9e5", size = 50087, upload-time = "2025-11-10T16:07:47.256Z" }+wheels = [+ { url = "https://files.pythonhosted.org/packages/e5/35/f8b19922b6a25bc0880171a2f1a003eaeb93657475193ab516fd87cac9da/pytest_asyncio-1.3.0-py3-none-any.whl", hash = "sha256:611e26147c7f77640e6d0a92a38ed17c3e9848063698d5c93d5aa7aa11cebff5", size = 15075, upload-time = "2025-11-10T16:07:45.537Z" },+]+[[package]]name = "python-dateutil"version = "2.9.0.post0"@@ -4362,6 +4385,7 @@ dependencies = [[package.optional-dependencies]dev = [{ name = "pytest" },+ { name = "pytest-asyncio" },{ name = "ruff" },]speech = [@@ -4401,6 +4425,7 @@ requires-dist = [{ name = "pynacl", specifier = ">=1.6.2" },{ name = "pysignalclirestapi", specifier = ">=0.3.24" },{ name = "pytest", marker = "extra == 'dev'", specifier = ">=8.4.1" },+ { name = "pytest-asyncio", marker = "extra == 'dev'", specifier = ">=0.24.0" },{ name = "python-dotenv", specifier = ">=1.0.0" },{ name = "python-levenshtein", specifier = ">=0.27.1" },{ name = "python-telegram-bot", specifier = ">=21.10" },