Skip to content

armgit / E2B

Public Imported from GitHub
0

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

Fix tests; Improve error handling; Circumvent compression error

Tomas Valentac1e1c1f67e56
diff --git a/packages/js-sdk/src/errors.ts b/packages/js-sdk/src/errors.ts
index b44f2d338..f3b016596 100644
--- a/packages/js-sdk/src/errors.ts
+++ b/packages/js-sdk/src/errors.ts
@@ -74,3 +74,13 @@ export class AuthenticationError extends SandboxError {
this.name = 'AuthenticationError'
}
}
+
+/**
+ * Thrown when the template uses old envd version. It isn't compatible with the new SDK.
+ */
+export class TemplateError extends SandboxError {
+ constructor(message: string) {
+ super(message)
+ this.name = 'TemplateError'
+ }
+}
diff --git a/packages/js-sdk/src/index.ts b/packages/js-sdk/src/index.ts
index c83083e0c..c00b6cbbc 100644
--- a/packages/js-sdk/src/index.ts
+++ b/packages/js-sdk/src/index.ts
@@ -10,6 +10,7 @@ export {
NotFoundError,
NotEnoughSpaceError,
InvalidArgumentError,
+ TemplateError,
} from './errors'
export {
ConnectionConfig,
diff --git a/packages/js-sdk/src/sandbox/process/index.ts b/packages/js-sdk/src/sandbox/process/index.ts
index d70219dd6..ada0c98ca 100644
--- a/packages/js-sdk/src/sandbox/process/index.ts
+++ b/packages/js-sdk/src/sandbox/process/index.ts
@@ -1,4 +1,6 @@
import {
+ Code,
+ ConnectError,
createPromiseClient,
PromiseClient,
Transport,
@@ -89,7 +91,7 @@ export class Process {
}
}
- async kill(pid: number, opts?: ProcessRequestOpts): Promise<void> {
+ async kill(pid: number, opts?: ProcessRequestOpts): Promise<boolean> {
try {
await this.rpc.sendSignal({
process: {
@@ -102,7 +104,15 @@ export class Process {
}, {
signal: this.connectionConfig.getSignal(opts?.requestTimeoutMs),
})
+
+ return true
} catch (err) {
+ if (err instanceof ConnectError) {
+ if (err.code === Code.NotFound) {
+ return false
+ }
+ }
+
throw handleRpcError(err)
}
}
diff --git a/packages/js-sdk/src/sandbox/process/processHandle.ts b/packages/js-sdk/src/sandbox/process/processHandle.ts
index 236e7b071..59ca0b5ab 100644
--- a/packages/js-sdk/src/sandbox/process/processHandle.ts
+++ b/packages/js-sdk/src/sandbox/process/processHandle.ts
@@ -55,7 +55,7 @@ export class ProcessHandle implements Omit<ProcessResult, 'exitCode' | 'error'>,
constructor(
readonly pid: number,
private readonly handleDisconnect: () => void,
- private readonly handleKill: () => Promise<void>,
+ private readonly handleKill: () => Promise<boolean>,
private readonly events: AsyncIterable<ConnectResponse | StartResponse>,
private readonly onStdout?: (stdout: string) => (void | Promise<void>),
private readonly onStderr?: (stderr: string) => (void | Promise<void>),
diff --git a/packages/js-sdk/src/sandbox/sandboxApi.ts b/packages/js-sdk/src/sandbox/sandboxApi.ts
index 7deb791c0..e43617d6c 100644
--- a/packages/js-sdk/src/sandbox/sandboxApi.ts
+++ b/packages/js-sdk/src/sandbox/sandboxApi.ts
@@ -1,6 +1,7 @@
import { ApiClient, handleApiError } from '../api'
import { ConnectionConfig, ConnectionOpts } from '../connectionConfig'
import { compareVersions } from 'compare-versions'
+import { TemplateError } from '../errors'
export interface SandboxApiOpts extends Partial<Pick<ConnectionOpts, 'apiKey' | 'debug' | 'domain' | 'requestTimeoutMs'>> { }
@@ -43,7 +44,7 @@ export class SandboxApi {
* @param sandboxID - Sandbox ID.
* @param opts - Connection options.
*/
- static async kill(sandboxID: string, opts?: SandboxApiOpts): Promise<void> {
+ static async kill(sandboxID: string, opts?: SandboxApiOpts): Promise<boolean> {
const config = new ConnectionConfig(opts)
const client = new ApiClient(config)
@@ -55,10 +56,16 @@ export class SandboxApi {
},
})
+ if (res.error?.code === 404) {
+ return false
+ }
+
const err = handleApiError(res.error)
if (err) {
throw err
}
+
+ return true
}
static async list(opts?: SandboxApiOpts): Promise<SandboxInfo[]> {
@@ -125,10 +132,11 @@ export class SandboxApi {
}
if (compareVersions(res.data!.envdVersion, '0.1.0') < 0) {
- throw new Error(
- 'You need to update the template to use the new SDK. ' +
- 'You can do this by running `e2b template build` in the directory with the template.'
- )
+ await this.kill(this.getSandboxID(res.data!), opts)
+ throw new TemplateError(
+ 'You need to update the template to use the new SDK. ' +
+ 'You can do this by running `e2b template build` in the directory with the template.'
+ )
}
return this.getSandboxID(res.data!)
}
diff --git a/packages/js-sdk/tests/api/kill.test.ts b/packages/js-sdk/tests/api/kill.test.ts
index 8017daf93..aa4457240 100644
--- a/packages/js-sdk/tests/api/kill.test.ts
+++ b/packages/js-sdk/tests/api/kill.test.ts
@@ -5,8 +5,11 @@ import { Sandbox } from '../../src'
sandboxTest.skipIf(isDebug)('kill existing sandbox', async ({ sandbox }) => {
await Sandbox.kill(sandbox.sandboxID)
+
+ const list = await Sandbox.list()
+ expect(list.map(s => s.sandboxID)).not.toContain(sandbox.sandboxID)
})
sandboxTest.skipIf(isDebug)('kill non-existing sandbox', async () => {
- await expect(Sandbox.kill('non-existing-sandbox')).rejects.toThrowError()
+ await expect(Sandbox.kill('non-existing-sandbox')).resolves.toBe(false)
})
diff --git a/packages/js-sdk/tests/sandbox/commands/kill.test.ts b/packages/js-sdk/tests/sandbox/commands/kill.test.ts
index 72a64c408..2cb6947ce 100644
--- a/packages/js-sdk/tests/sandbox/commands/kill.test.ts
+++ b/packages/js-sdk/tests/sandbox/commands/kill.test.ts
@@ -1,5 +1,4 @@
import { expect } from 'vitest'
-import { NotFoundError } from '../../../src/errors.js'
import { ProcessExitError } from '../../../src/index.js'
import { sandboxTest } from '../../setup.js'
@@ -16,5 +15,5 @@ sandboxTest('kill process', async ({ sandbox }) => {
sandboxTest('kill non-existing process', async ({ sandbox }) => {
const nonExistingPid = 999999
- await expect(sandbox.commands.kill(nonExistingPid)).rejects.toThrowError(NotFoundError)
+ await expect(sandbox.commands.kill(nonExistingPid)).resolves.toBe(false)
})
diff --git a/packages/js-sdk/tests/sandbox/kill.test.ts b/packages/js-sdk/tests/sandbox/kill.test.ts
index 53366b6a5..2ac2a88b9 100644
--- a/packages/js-sdk/tests/sandbox/kill.test.ts
+++ b/packages/js-sdk/tests/sandbox/kill.test.ts
@@ -1,9 +1,11 @@
import { expect } from 'vitest'
+import { Sandbox } from '../../src'
import { sandboxTest, isDebug } from '../setup.js'
sandboxTest.skipIf(isDebug)('kill', async ({ sandbox }) => {
await sandbox.kill()
- await expect(sandbox.isRunning()).rejects.toThrowError()
+ const list = await Sandbox.list()
+ expect(list.map(s => s.sandboxID)).not.toContain(sandbox.sandboxID)
})
diff --git a/packages/js-sdk/tests/sandbox/uploadUrl.test.ts b/packages/js-sdk/tests/sandbox/uploadUrl.test.ts
index 3c6798c80..73c777283 100644
--- a/packages/js-sdk/tests/sandbox/uploadUrl.test.ts
+++ b/packages/js-sdk/tests/sandbox/uploadUrl.test.ts
@@ -1,16 +1 @@
-
import { sandboxTest } from '../setup.js'
-
-sandboxTest('upload file via url', async ({ sandbox }) => {
- const url = sandbox.uploadUrl()
-
-
-})
-
-sandboxTest('upload file via url to specific path', async ({ sandbox }) => {
- const url = sandbox.uploadUrl('/test/test.txt')
-
- const res = await fetch(url)
-
- assert.equal(res.status, 200)
-})
diff --git a/packages/python-sdk/e2b/__init__.py b/packages/python-sdk/e2b/__init__.py
index 7dc4ccada..96f1b294a 100644
--- a/packages/python-sdk/e2b/__init__.py
+++ b/packages/python-sdk/e2b/__init__.py
@@ -5,7 +5,6 @@ from .api import (
from .connection_config import (
ConnectionConfig,
)
-
from .exceptions import (
SandboxException,
TimeoutException,
@@ -13,6 +12,7 @@ from .exceptions import (
AuthenticationException,
InvalidArgumentException,
NotEnoughSpaceException,
+ TemplateException,
)
from .sandbox.sandbox_api import SandboxInfo
from .sandbox.main import Sandbox
@@ -24,12 +24,10 @@ from .sandbox.process.process_handle import (
ProcessExitException,
)
from .sandbox.process.main import ProcessInfo
-
from .sandbox.filesystem.watch_handle import (
WatchHandle,
FilesystemEvent,
FilesystemEventType,
)
from .sandbox.filesystem.filesystem import EntryInfo, FileType
-
from .sandbox.main import Sandbox
diff --git a/packages/python-sdk/e2b/exceptions.py b/packages/python-sdk/e2b/exceptions.py
index 61fb9ab1a..8c39ab5d6 100644
--- a/packages/python-sdk/e2b/exceptions.py
+++ b/packages/python-sdk/e2b/exceptions.py
@@ -57,3 +57,9 @@ class AuthenticationException(SandboxException):
"""
pass
+
+
+class TemplateException(SandboxException):
+ """
+ Exception raised when the template uses old envd version. It isn't compatible with the new SDK.
+ """
diff --git a/packages/python-sdk/e2b/sandbox/filesystem/watch_handle.py b/packages/python-sdk/e2b/sandbox/filesystem/watch_handle.py
index 372e17a69..0616e518a 100644
--- a/packages/python-sdk/e2b/sandbox/filesystem/watch_handle.py
+++ b/packages/python-sdk/e2b/sandbox/filesystem/watch_handle.py
@@ -33,7 +33,7 @@ class FilesystemEvent:
type: FilesystemEventType
-class WatchHandle(Generator):
+class WatchHandle:
def __init__(
self,
events: Generator[WatchDirResponse, Any, None],
diff --git a/packages/python-sdk/e2b/sandbox/main.py b/packages/python-sdk/e2b/sandbox/main.py
index 14f07a8ad..b974a5576 100644
--- a/packages/python-sdk/e2b/sandbox/main.py
+++ b/packages/python-sdk/e2b/sandbox/main.py
@@ -158,8 +158,7 @@ class Sandbox(SandboxApi):
self.kill()
@overload
- def kill(self, request_timeout: Optional[float] = None) -> None:
- ...
+ def kill(self, request_timeout: Optional[float] = None) -> bool: ...
@overload
@staticmethod
@@ -169,11 +168,10 @@ class Sandbox(SandboxApi):
domain: Optional[str] = None,
debug: Optional[bool] = None,
request_timeout: Optional[float] = None,
- ) -> None:
- ...
+ ) -> bool: ...
@class_method_variant("_cls_kill")
- def kill(self, request_timeout: Optional[float] = None) -> None: # type: ignore
+ def kill(self, request_timeout: Optional[float] = None) -> bool: # type: ignore
config_dict = self._connection_config.__dict__
config_dict.pop("access_token", None)
config_dict.pop("api_url", None)
@@ -191,8 +189,7 @@ class Sandbox(SandboxApi):
self,
timeout: int,
request_timeout: Optional[float] = None,
- ) -> None:
- ...
+ ) -> None: ...
@overload
@staticmethod
@@ -203,8 +200,7 @@ class Sandbox(SandboxApi):
domain: Optional[str] = None,
debug: Optional[bool] = None,
request_timeout: Optional[float] = None,
- ) -> None:
- ...
+ ) -> None: ...
@class_method_variant("_cls_set_timeout")
def set_timeout( # type: ignore
diff --git a/packages/python-sdk/e2b/sandbox/process/main.py b/packages/python-sdk/e2b/sandbox/process/main.py
index 0f659420b..c2f9bd449 100644
--- a/packages/python-sdk/e2b/sandbox/process/main.py
+++ b/packages/python-sdk/e2b/sandbox/process/main.py
@@ -34,7 +34,8 @@ class Process:
self._connection_config = connection_config
self._rpc = process_connect.ProcessClient(
envd_api_url,
- compressor=connect.GzipCompressor,
+ # TODO: Fix and enable compression again — the headers compression is not solved.
+ # compressor=connect.GzipCompressor,
pool=pool,
)
@@ -67,7 +68,7 @@ class Process:
self,
pid: int,
request_timeout: Optional[float] = None,
- ):
+ ) -> bool:
try:
self._rpc.send_signal(
process_pb2.SendSignalRequest(
@@ -78,7 +79,11 @@ class Process:
request_timeout
),
)
+ return True
except Exception as e:
+ if isinstance(e, connect.ConnectException):
+ if e.status == connect.Code.not_found:
+ return False
raise handle_rpc_exception(e)
def send_stdin(
@@ -114,8 +119,7 @@ class Process:
on_stderr: Optional[Callable[[str], None]] = None,
timeout: Optional[float] = 60,
request_timeout: Optional[float] = None,
- ) -> ProcessResult:
- ...
+ ) -> ProcessResult: ...
@overload
def run(
@@ -129,8 +133,7 @@ class Process:
on_stderr: Optional[Callable[[str], None]] = None,
timeout: Optional[float] = 60,
request_timeout: Optional[float] = None,
- ) -> ProcessHandle:
- ...
+ ) -> ProcessHandle: ...
def run(
self,
diff --git a/packages/python-sdk/e2b/sandbox/process/process_handle.py b/packages/python-sdk/e2b/sandbox/process/process_handle.py
index 9a20cb443..332a205ac 100644
--- a/packages/python-sdk/e2b/sandbox/process/process_handle.py
+++ b/packages/python-sdk/e2b/sandbox/process/process_handle.py
@@ -28,18 +28,10 @@ class ProcessHandle:
def pid(self):
return self._pid
- @property
- def stdout(self):
- return self._stdout
-
- @property
- def stderr(self):
- return self._stderr
-
def __init__(
self,
pid: int,
- handle_kill: Callable[[], None],
+ handle_kill: Callable[[], bool],
events: Generator[
Union[process_pb2.StartResponse, process_pb2.ConnectResponse], Any, None
],
@@ -59,7 +51,11 @@ class ProcessHandle:
def _handle_events(
self,
- ) -> Generator[Union[Tuple[Stdout, None], Tuple[None, Stderr]], None, None,]:
+ ) -> Generator[
+ Union[Tuple[Stdout, None], Tuple[None, Stderr]],
+ None,
+ None,
+ ]:
try:
for event in self._events:
if event.event.HasField("data"):
diff --git a/packages/python-sdk/e2b/sandbox/sandbox_api.py b/packages/python-sdk/e2b/sandbox/sandbox_api.py
index 1595f101b..e45fb3b57 100644
--- a/packages/python-sdk/e2b/sandbox/sandbox_api.py
+++ b/packages/python-sdk/e2b/sandbox/sandbox_api.py
@@ -3,17 +3,12 @@ from typing import Optional, Dict, List
from datetime import datetime
from packaging.version import Version
+from e2b.exceptions import TemplateException
from e2b.api import ApiClient, models, client, exceptions
from e2b.connection_config import ConnectionConfig
from e2b.api import handle_api_exception
-class E2BUpdateTemplateException(Exception):
- """
- Exception raised when the template uses old envd version. It isn't compatible with the new SDK.
- """
-
-
@dataclass
class SandboxInfo:
"""Information about a sandbox."""
@@ -74,7 +69,7 @@ class SandboxApi:
domain: Optional[str] = None,
debug: Optional[bool] = None,
request_timeout: Optional[float] = None,
- ) -> None:
+ ) -> bool:
config = ConnectionConfig(
api_key=api_key,
domain=domain,
@@ -88,7 +83,10 @@ class SandboxApi:
sandbox_id,
_request_timeout=config.request_timeout,
)
+ return True
except exceptions.ApiException as e:
+ if e.status == 404:
+ return False
raise handle_api_exception(e)
@classmethod
@@ -147,7 +145,10 @@ class SandboxApi:
_request_timeout=config.request_timeout,
)
if Version(res.envd_version) < Version("0.1.0"):
- raise E2BUpdateTemplateException(
+ SandboxApi._cls_kill(
+ SandboxApi._get_sandbox_id(res.sandbox_id, res.client_id)
+ )
+ raise TemplateException(
"You need to update the template to use the new SDK. "
"You can do this by running `e2b template build` in the directory with the template."
)
diff --git a/packages/python-sdk/tests/api/test_sbx_kill.py b/packages/python-sdk/tests/api/test_sbx_kill.py
index e73157094..0958e657c 100644
--- a/packages/python-sdk/tests/api/test_sbx_kill.py
+++ b/packages/python-sdk/tests/api/test_sbx_kill.py
@@ -1,14 +1,16 @@
import pytest
-from e2b import Sandbox, SandboxException
+from e2b import Sandbox
@pytest.mark.skip_debug()
def test_kill_existing_sandbox(sandbox: Sandbox):
- Sandbox.kill(sandbox.sandbox_id)
+ assert Sandbox.kill(sandbox.sandbox_id) == True
+
+ list = Sandbox.list()
+ assert sandbox.sandbox_id not in [s.sandbox_id for s in list]
@pytest.mark.skip_debug()
def test_kill_non_existing_sandbox():
- with pytest.raises(SandboxException):
- Sandbox.kill("non-existing-sandbox")
+ assert Sandbox.kill("non-existing-sandbox") == False
diff --git a/packages/python-sdk/tests/bugs/test_envelope_decode.py b/packages/python-sdk/tests/bugs/test_envelope_decode.py
new file mode 100644
index 000000000..31a232118
--- /dev/null
+++ b/packages/python-sdk/tests/bugs/test_envelope_decode.py
@@ -0,0 +1,45 @@
+import uuid
+from e2b.sandbox.process.process_handle import ProcessExitException
+
+import pytest
+
+from e2b import Sandbox
+
+
+class Desktop(Sandbox):
+ default_template = "desktop"
+
+ @staticmethod
+ def _wrap_pyautogui_code(code: str):
+ return f"""
+import pyautogui
+import os
+import Xlib.display
+
+display = Xlib.display.Display(os.environ["DISPLAY"])
+pyautogui._pyautogui_x11._display = display
+
+{code}
+exit(0)
+"""
+
+ def pyautogui(self, pyautogui_code: str):
+ code_path = f"/home/user/code-4f3a0850-1a83-47b2-8402-67b039a084ae.py"
+ print(code_path)
+
+ code = self._wrap_pyautogui_code(pyautogui_code)
+
+ self.files.write(code_path, code)
+
+ self.commands.run(f"python {code_path}")
+
+
+def test_envelope_decode():
+ with Desktop(timeout=30) as desktop:
+ for _ in range(10):
+ with pytest.raises(ProcessExitException):
+ desktop.pyautogui(
+ """
+pyautogui.write("Hello, ")
+"""
+ )
diff --git a/packages/python-sdk/tests/sandbox/commands/test_cmd_kill.py b/packages/python-sdk/tests/sandbox/commands/test_cmd_kill.py
index 95a190c81..ed9e21bd3 100644
--- a/packages/python-sdk/tests/sandbox/commands/test_cmd_kill.py
+++ b/packages/python-sdk/tests/sandbox/commands/test_cmd_kill.py
@@ -1,20 +1,19 @@
import pytest
-from e2b import NotFoundException
+from e2b import Sandbox, ProcessExitException
-def test_kill_process(sandbox):
+def test_kill_process(sandbox: Sandbox):
cmd = sandbox.commands.run("sleep 10", background=True)
pid = cmd.pid
sandbox.commands.kill(pid)
- with pytest.raises(NotFoundException):
+ with pytest.raises(ProcessExitException):
sandbox.commands.run(f"kill -0 {pid}")
def test_kill_non_existing_process(sandbox):
non_existing_pid = 999999
- with pytest.raises(NotFoundException):
- sandbox.commands.kill(non_existing_pid)
+ assert sandbox.commands.kill(non_existing_pid) == False
diff --git a/packages/python-sdk/tests/sandbox/commands/test_cmd_list.py b/packages/python-sdk/tests/sandbox/commands/test_cmd_list.py
index 4d9ae9661..30bedb510 100644
--- a/packages/python-sdk/tests/sandbox/commands/test_cmd_list.py
+++ b/packages/python-sdk/tests/sandbox/commands/test_cmd_list.py
@@ -1,9 +1,13 @@
-def test_kill_process(sandbox):
- sandbox.commands.run("sleep 10", background=True)
- sandbox.commands.run("sleep 10", background=True)
+from e2b import Sandbox
+
+
+def test_kill_process(sandbox: Sandbox):
+ c1 = sandbox.commands.run("sleep 10", background=True)
+ c2 = sandbox.commands.run("sleep 10", background=True)
processes = sandbox.commands.list()
assert len(processes) >= 2
- for process in processes:
- assert "pid" in process
+ pids = [p.pid for p in processes]
+ assert c1.pid in pids
+ assert c2.pid in pids
diff --git a/packages/python-sdk/tests/sandbox/commands/test_run.py b/packages/python-sdk/tests/sandbox/commands/test_run.py
index acc3c930d..337844e26 100644
--- a/packages/python-sdk/tests/sandbox/commands/test_run.py
+++ b/packages/python-sdk/tests/sandbox/commands/test_run.py
@@ -1,7 +1,9 @@
import pytest
+from e2b import Sandbox
-def test_run(sandbox):
+
+def test_run(sandbox: Sandbox):
text = "Hello, World!"
cmd = sandbox.commands.run(f'echo "{text}"')
@@ -10,7 +12,7 @@ def test_run(sandbox):
assert cmd.stdout == f"{text}\n"
-def test_run_with_special_characters(sandbox):
+def test_run_with_special_characters(sandbox: Sandbox):
text = "!@#$%^&*()_+"
cmd = sandbox.commands.run(f'echo "{text}"')
diff --git a/packages/python-sdk/tests/sandbox/commands/test_send_stdin.py b/packages/python-sdk/tests/sandbox/commands/test_send_stdin.py
index 7126ab81f..640cdf340 100644
--- a/packages/python-sdk/tests/sandbox/commands/test_send_stdin.py
+++ b/packages/python-sdk/tests/sandbox/commands/test_send_stdin.py
@@ -1,26 +1,28 @@
-def test_send_stdin_to_process(sandbox):
- cmd = sandbox.commands.run("cat", background=True)
- sandbox.commands.send_stdin(cmd.pid, "Hello, World!")
- cmd.kill()
- assert cmd.stdout == "Hello, World!"
+from e2b import Sandbox
-def test_send_empty_stdin_to_process(sandbox):
+def test_send_stdin_to_process(sandbox: Sandbox):
cmd = sandbox.commands.run("cat", background=True)
- sandbox.commands.send_stdin(cmd.pid, "")
- cmd.kill()
- assert cmd.stdout == ""
+ sandbox.commands.send_stdin(cmd.pid, "Hello, World!")
+ for stdout, _ in cmd:
+ assert stdout == "Hello, World!"
+ break
-def test_send_special_characters_to_process(sandbox):
+
+def test_send_special_characters_to_process(sandbox: Sandbox):
cmd = sandbox.commands.run("cat", background=True)
sandbox.commands.send_stdin(cmd.pid, "!@#$%^&*()_+")
- cmd.kill()
- assert cmd.stdout == "!@#$%^&*()_+"
+
+ for stdout, _ in cmd:
+ assert stdout == "!@#$%^&*()_+"
+ break
-def test_send_multiline_string_to_process(sandbox):
+def test_send_multiline_string_to_process(sandbox: Sandbox):
cmd = sandbox.commands.run("cat", background=True)
sandbox.commands.send_stdin(cmd.pid, "Hello,\nWorld!")
- cmd.kill()
- assert cmd.stdout == "Hello,\nWorld!"
+
+ for stdout, _ in cmd:
+ assert stdout == "Hello,\nWorld!"
+ break
diff --git a/packages/python-sdk/tests/sandbox/test_kill.py b/packages/python-sdk/tests/sandbox/test_kill.py
index e7b417df9..855a85c7a 100644
--- a/packages/python-sdk/tests/sandbox/test_kill.py
+++ b/packages/python-sdk/tests/sandbox/test_kill.py
@@ -6,5 +6,6 @@ from e2b.sandbox.main import Sandbox
@pytest.mark.skip_debug()
def test_kill(sandbox: Sandbox):
sandbox.kill()
- with pytest.raises(Exception):
- sandbox.is_running()
+
+ list = Sandbox.list()
+ assert sandbox.sandbox_id not in [s.sandbox_id for s in list]
diff --git a/packages/python-sdk/tests/sandbox/test_timeout.py b/packages/python-sdk/tests/sandbox/test_timeout.py
index 37f3db1e9..2ca5e55c9 100644
--- a/packages/python-sdk/tests/sandbox/test_timeout.py
+++ b/packages/python-sdk/tests/sandbox/test_timeout.py
@@ -1,4 +1,5 @@
from time import sleep
+from e2b.exceptions import TimeoutException
import pytest
@@ -9,7 +10,7 @@ from e2b import NotFoundException
def test_shorten_timeout(sandbox):
sandbox.set_timeout(5)
sleep(6)
- with pytest.raises(NotFoundException):
+ with pytest.raises(TimeoutException):
sandbox.is_running()
diff --git a/packages/python-sdk/tests/sandbox/test_upload_url.py b/packages/python-sdk/tests/sandbox/test_upload_url.py
index 9f7eab2f5..20b15530d 100644
--- a/packages/python-sdk/tests/sandbox/test_upload_url.py
+++ b/packages/python-sdk/tests/sandbox/test_upload_url.py
@@ -1,17 +1 @@
import requests
-
-
-
-#TODO: Upload and check if the file is uploaded
-def test_upload_file_via_url(sandbox):
- url = sandbox.upload_url()
- res = requests.get(url)
- assert res.status_code == 200
-
-
-def test_upload_file_via_url_to_specific_path(sandbox):
- url = sandbox.upload_url("/test/test.txt")
- assert "test.txt" in url
-
- res = requests.get(url)
- assert res.status_code == 200