From b0746c0844285b2450af74ae8a7f8e84ac998f4f Mon Sep 17 00:00:00 2001 From: Liangshanbobo <78805926+liang0417@users.noreply.github.com> Date: Mon, 7 Sep 2026 17:05:16 +0800 Subject: [PATCH] test(tools): run wait async tests with anyio --- lib/crewai-tools/tests/tools/wait_tool_test.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/crewai-tools/tests/tools/wait_tool_test.py b/lib/crewai-tools/tests/tools/wait_tool_test.py index 22864231e7..5b72648dc7 100644 --- a/lib/crewai-tools/tests/tools/wait_tool_test.py +++ b/lib/crewai-tools/tests/tools/wait_tool_test.py @@ -10,6 +10,11 @@ def tool(): return WaitTool() +@pytest.fixture +def anyio_backend(): + return "asyncio" + + @patch("crewai_tools.tools.wait_tool.wait_tool.time.sleep") def test_waits_requested_duration(mock_sleep, tool): result = tool.run(seconds=2) @@ -65,7 +70,8 @@ def test_negative_seconds_is_rejected_when_passed_positionally(mock_sleep, tool) mock_sleep.assert_not_called() -@pytest.mark.asyncio +@pytest.mark.block_network(allowed_hosts=[r"127\.0\.0\.1"]) +@pytest.mark.anyio async def test_async_negative_seconds_is_rejected_when_passed_positionally(tool): with patch( "crewai_tools.tools.wait_tool.wait_tool.asyncio.sleep", new_callable=AsyncMock @@ -106,7 +112,8 @@ def test_invalid_max_seconds_is_rejected(): WaitTool(max_seconds=0) -@pytest.mark.asyncio +@pytest.mark.block_network(allowed_hosts=[r"127\.0\.0\.1"]) +@pytest.mark.anyio async def test_async_wait_caps_long_waits(tool): with patch( "crewai_tools.tools.wait_tool.wait_tool.asyncio.sleep", new_callable=AsyncMock