Skip to content

armgit / E2B

Public Imported from GitHub
0

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

Fix timeouts in tests

Tomas Valentac4c888dcc814
diff --git a/packages/python-sdk/tests/async/sandbox_async/commands/test_run.py b/packages/python-sdk/tests/async/sandbox_async/commands/test_run.py
index 87cd1af53..9bfb48747 100644
--- a/packages/python-sdk/tests/async/sandbox_async/commands/test_run.py
+++ b/packages/python-sdk/tests/async/sandbox_async/commands/test_run.py
@@ -1,6 +1,6 @@
import pytest
-from e2b import AsyncSandbox
+from e2b import AsyncSandbox, TimeoutException
@pytest.mark.asyncio
@@ -35,12 +35,12 @@ async def test_run_with_multiline_string(async_sandbox: AsyncSandbox):
@pytest.mark.asyncio
async def test_run_with_timeout(async_sandbox: AsyncSandbox):
- cmd = await async_sandbox.commands.run('echo "Hello, World!"', timeout=1000)
+ cmd = await async_sandbox.commands.run('echo "Hello, World!"', timeout=10)
assert cmd.exit_code == 0
@pytest.mark.asyncio
async def test_run_with_too_short_timeout(async_sandbox: AsyncSandbox):
- with pytest.raises(Exception):
- await async_sandbox.commands.run("sleep 10", timeout=1000)
+ with pytest.raises(TimeoutException):
+ await async_sandbox.commands.run("sleep 10", timeout=2)
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 337844e26..4abd3f92b 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
@@ -1,6 +1,6 @@
import pytest
-from e2b import Sandbox
+from e2b import Sandbox, TimeoutException
def test_run(sandbox: Sandbox):
@@ -31,11 +31,11 @@ def test_run_with_multiline_string(sandbox):
def test_run_with_timeout(sandbox):
- cmd = sandbox.commands.run('echo "Hello, World!"', timeout=1000)
+ cmd = sandbox.commands.run('echo "Hello, World!"', timeout=10)
assert cmd.exit_code == 0
def test_run_with_too_short_timeout(sandbox):
- with pytest.raises(Exception):
- sandbox.commands.run("sleep 10", timeout_ms=1000)
+ with pytest.raises(TimeoutException):
+ sandbox.commands.run("sleep 10", timeout=2)