Your lightweight open-source personal agent.
Python agent-frameworkai-agentai-agentschatbotchatopsdiscord-botllm-agentsllmslocal-llmmcpmodel-context-protocolmulti-agentopenai-compatibleopenclawpersonal-ai-assistantpythonself-hostedtelegram-bot-ai-assistantwebuiworkflow-automation
test(shell): wait for Windows PowerShell sessions
chengyongru9f8c2cb1bf74
diff --git a/tests/tools/test_exec_platform.py b/tests/tools/test_exec_platform.pyindex c47440abf..beb8d4743 100644--- a/tests/tools/test_exec_platform.py+++ b/tests/tools/test_exec_platform.py@@ -12,7 +12,7 @@ from unittest.mock import AsyncMock, patchimport pytest-from nanobot.agent.tools.exec_session import ExecSessionManager+from nanobot.agent.tools.exec_session import ExecSessionManager, WriteStdinToolfrom nanobot.agent.tools.shell import ExecTool_WINDOWS_ENV_KEYS = {@@ -756,7 +756,7 @@ class TestWindowsRealExec:@pytest.mark.asyncioasync def test_windows_powershell_output_is_utf8(self):- result = await ExecTool(timeout=10).execute(+ result = await ExecTool(timeout=60).execute(command=("Write-Output 'café λ 你好'; ""[Console]::Error.WriteLine('warn λ 你好')"@@ -770,24 +770,43 @@ class TestWindowsRealExec:@pytest.mark.asyncioasync def test_windows_powershell_redirection_avoids_utf16(self, tmp_path):- result = await ExecTool(working_dir=str(tmp_path), timeout=10).execute(+ result = await ExecTool(working_dir=str(tmp_path), timeout=60).execute(command="Write-Output 'café λ 你好' > marker.txt",shell="powershell",)- data = (tmp_path / "marker.txt").read_bytes()-assert "Exit code: 0" in result++ data = (tmp_path / "marker.txt").read_bytes()assert b"\x00" not in dataassert data.decode("utf-8-sig").strip() == "café λ 你好"@pytest.mark.asyncioasync def test_windows_powershell_session_output_is_utf8(self):manager = ExecSessionManager()- result = await ExecTool(timeout=10, session_manager=manager).execute(- command="Write-Output 'café λ 你好'",+ result = await ExecTool(timeout=60, session_manager=manager).execute(+ command="Start-Sleep -Milliseconds 1500; Write-Output 'café λ 你好'",shell="powershell",yield_time_ms=1000,)+ if "session_id:" in result:+ session_id = result.split("session_id:", 1)[1].splitlines()[0].strip()+ poll_result = await WriteStdinTool(manager=manager).execute(+ session_id=session_id,+ chars="",+ wait_for="café λ 你好",+ wait_timeout_ms=60_000,+ )+ result += "\n" + poll_result+ if "Process running." in poll_result:+ final_result = await WriteStdinTool(manager=manager).execute(+ session_id=session_id,+ chars="",+ yield_time_ms=30_000,+ )+ result += "\n" + final_result+ assert "Process running." not in final_result+assert "café λ 你好" in result+ assert "Exit code: 0" in resultassert "\x00" not in result