Skip to content

Commit a90318a

Browse files
committed
x
1 parent 86fa65a commit a90318a

File tree

1 file changed

+45
-6
lines changed
  • libs/standard-tests/langchain_tests/integration_tests

1 file changed

+45
-6
lines changed

libs/standard-tests/langchain_tests/integration_tests/sandboxes.py

Lines changed: 45 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ def sandbox(self) -> Iterator[SandboxBackendProtocol]:
3232

3333
from __future__ import annotations
3434

35+
import asyncio
3536
import base64
3637
import shlex
3738
from abc import abstractmethod
@@ -188,10 +189,26 @@ def test_read_binary_file_1_mib_returns_error(
188189

189190
assert isinstance(result, ReadResult)
190191
assert result.file_data is None
191-
assert (
192-
result.error
193-
== f"File '{test_path}': Binary file exceeds maximum preview size of 512000 bytes"
192+
expected_error = (
193+
f"File '{test_path}': Binary file exceeds maximum preview size of "
194+
"512000 bytes"
194195
)
196+
assert result.error == expected_error
197+
198+
def test_execute_large_stdout_payload(
199+
self, sandbox_backend: SandboxBackendProtocol
200+
) -> None:
201+
"""Execute should handle a command that emits about 500 KiB of stdout."""
202+
if not self.has_sync:
203+
pytest.skip("Sync tests not supported.")
204+
205+
command = "python -c \"import sys; sys.stdout.write('x' * (500 * 1024))\""
206+
result = sandbox_backend.execute(command)
207+
208+
assert result.exit_code == 0
209+
assert result.truncated is False
210+
assert len(result.output) >= 500 * 1024
211+
assert result.output.startswith("x")
195212

196213
def test_edit_single_occurrence(
197214
self, sandbox_backend: SandboxBackendProtocol, sandbox_test_root: str
@@ -1807,10 +1824,32 @@ async def test_aread_binary_file_1_mib_returns_error(
18071824
result = await sandbox_backend.aread(test_path)
18081825
assert isinstance(result, ReadResult)
18091826
assert result.file_data is None
1810-
assert (
1811-
result.error
1812-
== f"File '{test_path}': Binary file exceeds maximum preview size of 512000 bytes"
1827+
expected_error = (
1828+
f"File '{test_path}': Binary file exceeds maximum preview size of "
1829+
"512000 bytes"
18131830
)
1831+
assert result.error == expected_error
1832+
1833+
async def test_aexecute_large_stdout_payload(
1834+
self, sandbox_backend: SandboxBackendProtocol
1835+
) -> None:
1836+
"""Async execute should handle five parallel 500 KiB stdout commands."""
1837+
if not self.has_async:
1838+
pytest.skip("Async tests not supported.")
1839+
1840+
command = "python -c \"import sys; sys.stdout.write('x' * (500 * 1024))\""
1841+
tasks: list[asyncio.Task] = []
1842+
async with asyncio.TaskGroup() as tg:
1843+
tasks.extend(
1844+
tg.create_task(sandbox_backend.aexecute(command)) for _ in range(5)
1845+
)
1846+
1847+
for task in tasks:
1848+
result = task.result()
1849+
assert result.exit_code == 0
1850+
assert result.truncated is False
1851+
assert len(result.output) >= 500 * 1024
1852+
assert result.output.startswith("x")
18141853

18151854
async def test_aupload_adownload_large_file_roundtrip(
18161855
self, sandbox_backend: SandboxBackendProtocol, sandbox_test_root: str

0 commit comments

Comments
 (0)