Skip to content

armgit / E2B

Public Imported from GitHub
0

Open-source, secure environment with real-world tools for enterprise-grade agents.

Add test

Jakub Novakae61d831d2f2
diff --git a/packages/python-sdk/tests/sync/sandbox_sync/commands/test_run.py b/packages/python-sdk/tests/sync/sandbox_sync/commands/test_run.py
index 67072cd78..e75e5ba32 100644
--- a/packages/python-sdk/tests/sync/sandbox_sync/commands/test_run.py
+++ b/packages/python-sdk/tests/sync/sandbox_sync/commands/test_run.py
@@ -20,14 +20,16 @@ def test_run_with_special_characters(sandbox: Sandbox):
assert cmd.exit_code == 0
assert cmd.stdout == f"{text}\n"
+
def test_run_with_broken_utf8(sandbox: Sandbox):
# Create a string with 8191 'a' characters followed by the problematic byte 0xe2
- long_str = 'a' * 8191 + '\\xe2'
+ long_str = "a" * 8191 + "\\xe2"
result = sandbox.commands.run(f'printf "{long_str}"')
assert result.exit_code == 0
# The broken UTF-8 bytes should be replaced with the Unicode replacement character
- assert result.stdout == ('a' * 8191 + '\ufffd')
+ assert result.stdout == ("a" * 8191 + "\ufffd")
+
def test_run_with_multiline_string(sandbox):
text = "Hello,\nWorld!"
@@ -47,3 +49,10 @@ def test_run_with_timeout(sandbox):
def test_run_with_too_short_timeout(sandbox):
with pytest.raises(TimeoutException):
sandbox.commands.run("sleep 10", timeout=2)
+
+
+def test_run_with_too_short_timeout_iterating(sandbox):
+ cmd = sandbox.commands.run("sleep 10", timeout=2, background=True)
+ with pytest.raises(TimeoutException):
+ for _ in cmd:
+ pass