Files
ai-agent-book/chapter4/execution-tools/test_multilang_output.py
T
liqiang b119135836
Build latest book artifacts / build (push) Canceled after 0s
dependency resolution / resolve (3.11) (push) Canceled after 0s
dependency resolution / resolve (3.13) (push) Canceled after 0s
deploy-pages / build (push) Canceled after 0s
deploy-pages / deploy (push) Canceled after 0s
i18n consistency check / check (push) Canceled after 0s
provider adoption tests / test (chapter2/context-compression) (push) Canceled after 0s
provider adoption tests / test (chapter2/prompt-injection) (push) Canceled after 0s
provider adoption tests / test (chapter2/system-hint) (push) Canceled after 0s
provider adoption tests / test (chapter3/log-sanitization) (push) Canceled after 0s
web-search-agent tests / test (push) Canceled after 0s
web-search-agent tests / agentbook (push) Canceled after 0s
ai-agent-book 精选快照(<2MB 代码与文档,来自 github.com/bojieli/ai-agent-book)
2026-08-20 13:12:50 +00:00

30 lines
877 B
Python

import asyncio
import pytest
from multilang_executor import get_all_output, LanguageExecutor, ExecutionStatus
@pytest.mark.asyncio
async def test_get_all_output_reads_full_payload():
class FakeStream:
def __init__(self, data: bytes):
self._data = data
self._done = False
async def read(self, n: int = -1):
if self._done:
return b""
self._done = True
return self._data
payload = b"hello world" * 1000
out = await get_all_output(FakeStream(payload))
assert out == payload.decode()
@pytest.mark.asyncio
async def test_execute_captures_stdout():
exe = LanguageExecutor()
result = await exe.execute_code("print('ok-from-executor')", "python", timeout=10)
assert result["status"] == ExecutionStatus.SUCCESS
assert "ok-from-executor" in result["stdout"]