Skip to content

armgit / E2B

Public Imported from GitHub
0

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

[WIP] Update tests

Tomas Valenta089f04ed1d32
diff --git a/packages/js-sdk/src/sandbox/filesystem/index.ts b/packages/js-sdk/src/sandbox/filesystem/index.ts
index 79428a3f0..756db8f58 100644
--- a/packages/js-sdk/src/sandbox/filesystem/index.ts
+++ b/packages/js-sdk/src/sandbox/filesystem/index.ts
@@ -181,7 +181,7 @@ export class Filesystem {
}
}
- async rename(oldPath: string, newPath: string, opts?: FilesystemRequestOpts): Promise<boolean> {
+ async rename(oldPath: string, newPath: string, opts?: FilesystemRequestOpts): Promise<void> {
try {
await this.rpc.move({
source: oldPath,
@@ -195,8 +195,6 @@ export class Filesystem {
}, {
signal: this.connectionConfig.getSignal(opts?.requestTimeoutMs),
})
-
- return true
} catch (err) {
throw handleRpcError(err)
}
diff --git a/packages/js-sdk/src/sandbox/filesystem/watchHandle.ts b/packages/js-sdk/src/sandbox/filesystem/watchHandle.ts
index 0107f17c6..35fd1da0c 100644
--- a/packages/js-sdk/src/sandbox/filesystem/watchHandle.ts
+++ b/packages/js-sdk/src/sandbox/filesystem/watchHandle.ts
@@ -44,7 +44,7 @@ export class WatchHandle {
this._wait = this.handleEvents()
}
- async stop() {
+ async close() {
this.handleStop()
}
@@ -60,7 +60,7 @@ export class WatchHandle {
} catch (err) {
throw handleRpcError(err)
} finally {
- this.stop()
+ this.close()
}
}
diff --git a/packages/js-sdk/tests/api/kill.test.mts b/packages/js-sdk/tests/api/kill.test.mts
index 9b7b3ab5c..d6d92a443 100644
--- a/packages/js-sdk/tests/api/kill.test.mts
+++ b/packages/js-sdk/tests/api/kill.test.mts
@@ -1,12 +1,12 @@
import { assert } from 'vitest'
-import { sandboxTest } from '../setup.mjs'
+import { sandboxTest, isDebug } from '../setup.mjs'
import { Sandbox } from '../../src'
-sandboxTest.skipIf(process.env.E2B_DEBUG)('kill existing sandbox', async ({ sandbox }) => {
+sandboxTest.skipIf(isDebug)('kill existing sandbox', async ({ sandbox }) => {
assert.doesNotThrow(() => Sandbox.kill(sandbox.sandboxID))
})
-sandboxTest.skipIf(process.env.E2B_DEBUG)('kill non-existing sandbox', async () => {
+sandboxTest.skipIf(isDebug)('kill non-existing sandbox', async () => {
assert.throws(() => Sandbox.kill('non-existing-sandbox'))
})
diff --git a/packages/js-sdk/tests/api/list.test.mts b/packages/js-sdk/tests/api/list.test.mts
index b18499551..871593ff4 100644
--- a/packages/js-sdk/tests/api/list.test.mts
+++ b/packages/js-sdk/tests/api/list.test.mts
@@ -1,9 +1,9 @@
import { assert } from 'vitest'
import { Sandbox } from '../../src'
-import { sandboxTest } from '../setup.mjs'
+import { sandboxTest, isDebug } from '../setup.mjs'
-sandboxTest.skipIf(process.env.E2B_DEBUG)('list sandboxes', async ({ sandbox }) => {
+sandboxTest.skipIf(isDebug)('list sandboxes', async ({ sandbox }) => {
const sandboxes = await Sandbox.list()
assert.isAtLeast(sandboxes.length, 1)
assert.include(sandboxes.map((s) => s.sandboxID), sandbox.sandboxID)
diff --git a/packages/js-sdk/tests/sandbox/commands/connect.test.mts b/packages/js-sdk/tests/sandbox/commands/connect.test.mts
index e69de29bb..27bf2279b 100644
--- a/packages/js-sdk/tests/sandbox/commands/connect.test.mts
+++ b/packages/js-sdk/tests/sandbox/commands/connect.test.mts
@@ -0,0 +1,22 @@
+import { assert } from 'vitest'
+import { sandboxTest } from '../../setup.mjs'
+
+sandboxTest('connect to process', async ({ sandbox }) => {
+ const cmd = await sandbox.commands.run('sleep 10', { background: true })
+ const pid = cmd.pid
+
+ const processInfo = await sandbox.commands.connect(pid)
+
+ assert.isObject(processInfo)
+ assert.equal(processInfo.pid, pid)
+})
+
+sandboxTest('connect to non-existing process', async ({ sandbox }) => {
+ const nonExistingPid = 999999
+
+ try {
+ await sandbox.commands.connect(nonExistingPid)
+ } catch (error) {
+ assert.instanceOf(error, Error)
+ }
+})
diff --git a/packages/js-sdk/tests/sandbox/commands/kill.test.mts b/packages/js-sdk/tests/sandbox/commands/kill.test.mts
index e69de29bb..cf8bb5b31 100644
--- a/packages/js-sdk/tests/sandbox/commands/kill.test.mts
+++ b/packages/js-sdk/tests/sandbox/commands/kill.test.mts
@@ -0,0 +1,25 @@
+import { assert } from 'vitest'
+import { sandboxTest } from '../../setup.mjs'
+
+sandboxTest('kill process', async ({ sandbox }) => {
+ const cmd = await sandbox.commands.run('sleep 10', { background: true })
+ const pid = cmd.pid
+
+ await sandbox.commands.kill(pid)
+
+ try {
+ await sandbox.commands.run(`kill -0 ${pid}`)
+ } catch (error) {
+ assert.instanceOf(error, Error)
+ }
+})
+
+sandboxTest('kill non-existing process', async ({ sandbox }) => {
+ const nonExistingPid = 999999
+
+ try {
+ await sandbox.commands.kill(nonExistingPid)
+ } catch (error) {
+ assert.instanceOf(error, Error)
+ }
+})
diff --git a/packages/js-sdk/tests/sandbox/commands/list.test.mts b/packages/js-sdk/tests/sandbox/commands/list.test.mts
index e69de29bb..051e1d9b8 100644
--- a/packages/js-sdk/tests/sandbox/commands/list.test.mts
+++ b/packages/js-sdk/tests/sandbox/commands/list.test.mts
@@ -0,0 +1,17 @@
+import { assert } from 'vitest'
+import { sandboxTest } from '../../setup.mjs'
+
+sandboxTest('list processes', async ({ sandbox }) => {
+ // Start them firsts
+ await sandbox.commands.run('sleep 10', { background: true })
+ await sandbox.commands.run('sleep 10', { background: true })
+
+ const processes = await sandbox.commands.list()
+
+ assert.isArray(processes)
+ assert.isAtLeast(processes.length, 2)
+
+ processes.forEach(process => {
+ assert.containsAllKeys(process, ['pid'])
+ })
+})
diff --git a/packages/js-sdk/tests/sandbox/commands/run.test.mts b/packages/js-sdk/tests/sandbox/commands/run.test.mts
index 7ef826df3..ae09b5e9f 100644
--- a/packages/js-sdk/tests/sandbox/commands/run.test.mts
+++ b/packages/js-sdk/tests/sandbox/commands/run.test.mts
@@ -9,3 +9,23 @@ sandboxTest('run', async ({ sandbox }) => {
assert.equal(cmd.exitCode, 0)
assert.equal(cmd.stdout, `${text}\n`)
})
+
+sandboxTest('run with special characters', async ({ sandbox }) => {
+ const text = '!@#$%^&*()_+'
+
+ const cmd = await sandbox.commands.run(`echo "${text}"`)
+
+ console.log('cmd', cmd)
+
+ assert.equal(cmd.exitCode, 0)
+ assert.equal(cmd.stdout, `${text}\n`)
+})
+
+sandboxTest('run with multiline string', async ({ sandbox }) => {
+ const text = 'Hello,\nWorld!'
+
+ const cmd = await sandbox.commands.run(`echo "${text}"`)
+
+ assert.equal(cmd.exitCode, 0)
+ assert.equal(cmd.stdout, `${text}\n`)
+})
diff --git a/packages/js-sdk/tests/sandbox/commands/sendStdin.test.mts b/packages/js-sdk/tests/sandbox/commands/sendStdin.test.mts
index e69de29bb..aeed3ba00 100644
--- a/packages/js-sdk/tests/sandbox/commands/sendStdin.test.mts
+++ b/packages/js-sdk/tests/sandbox/commands/sendStdin.test.mts
@@ -0,0 +1,63 @@
+import { assert } from 'vitest'
+import { ProcessExitError } from '../../../src/index.js'
+import { sandboxTest } from '../../setup.mjs'
+
+sandboxTest('send stdin to process', async ({ sandbox }) => {
+ const text = 'Hello, World!'
+ const cmd = await sandbox.commands.run('cat', { background: true })
+
+ await sandbox.commands.sendStdin(cmd.pid, text)
+
+ try {
+ await cmd.kill()
+ } catch (error) {
+ assert.instanceOf(error, ProcessExitError)
+ }
+
+ assert.equal(cmd.stdout, text)
+})
+
+sandboxTest('send empty stdin to process', async ({ sandbox }) => {
+ const text = ''
+ const cmd = await sandbox.commands.run('cat', { background: true })
+
+ await sandbox.commands.sendStdin(cmd.pid, text)
+
+ try {
+ await cmd.kill()
+ } catch (error) {
+ assert.instanceOf(error, ProcessExitError)
+ }
+
+ assert.equal(cmd.stdout, text)
+})
+
+sandboxTest('send special characters to stdin', async ({ sandbox }) => {
+ const text = '!@#$%^&*()_+'
+ const cmd = await sandbox.commands.run('cat', { background: true })
+
+ await sandbox.commands.sendStdin(cmd.pid, text)
+
+ try {
+ await cmd.kill()
+ } catch (error) {
+ assert.instanceOf(error, ProcessExitError)
+ }
+
+ assert.equal(cmd.stdout, text)
+})
+
+sandboxTest('send multiline string to stdin', async ({ sandbox }) => {
+ const text = 'Hello,\nWorld!'
+ const cmd = await sandbox.commands.run('cat', { background: true })
+
+ await sandbox.commands.sendStdin(cmd.pid, text)
+
+ try {
+ await cmd.kill()
+ } catch (error) {
+ assert.instanceOf(error, ProcessExitError)
+ }
+
+ assert.equal(cmd.stdout, text)
+})
diff --git a/packages/js-sdk/tests/sandbox/connect.test.mts b/packages/js-sdk/tests/sandbox/connect.test.mts
index ab028ff0a..20d2b24ab 100644
--- a/packages/js-sdk/tests/sandbox/connect.test.mts
+++ b/packages/js-sdk/tests/sandbox/connect.test.mts
@@ -1,13 +1,13 @@
import { test, assert } from 'vitest'
import { Sandbox } from '../../src'
-import { template } from '../setup.mts'
+import { template } from '../setup.mjs'
test('connect', async () => {
const sbx = await Sandbox.create(template, { timeoutMs: 10_000 })
const isRunning = await sbx.isRunning()
assert.isTrue(isRunning)
-
+
const sbxConnection = await Sandbox.connect(sbx.sandboxID)
const isRunning2 = await sbxConnection.isRunning()
assert.isTrue(isRunning2)
diff --git a/packages/js-sdk/tests/sandbox/create.test.mts b/packages/js-sdk/tests/sandbox/create.test.mts
index 23e1462a1..c4b0842c0 100644
--- a/packages/js-sdk/tests/sandbox/create.test.mts
+++ b/packages/js-sdk/tests/sandbox/create.test.mts
@@ -1,10 +1,23 @@
import { test, assert } from 'vitest'
import { Sandbox } from '../../src'
-import { template } from '../setup.mjs'
+import { template, isDebug } from '../setup.mjs'
-test('create', async () => {
+test.skipIf(isDebug)('create', async () => {
const sbx = await Sandbox.create(template, { timeoutMs: 5_000 })
const isRunning = await sbx.isRunning()
assert.isTrue(isRunning)
})
+
+test.skipIf(isDebug)('metadata', async () => {
+ const metadata = {
+ 'test-key': 'test-value',
+ }
+
+ const sbx = await Sandbox.create(template, { timeoutMs: 5_000, metadata })
+
+ const sbxs = await Sandbox.list()
+ const sbxInfo = sbxs.find((s) => s.sandboxID === sbx.sandboxID)
+
+ assert.deepEqual(sbxInfo?.metadata, metadata)
+})
diff --git a/packages/js-sdk/tests/sandbox/files/makeDir.test.mts b/packages/js-sdk/tests/sandbox/files/makeDir.test.mts
index e69de29bb..2787bf6ba 100644
--- a/packages/js-sdk/tests/sandbox/files/makeDir.test.mts
+++ b/packages/js-sdk/tests/sandbox/files/makeDir.test.mts
@@ -0,0 +1,19 @@
+import { assert } from 'vitest'
+
+import { sandboxTest } from '../../setup.mjs'
+
+sandboxTest('make directory', async ({ sandbox }) => {
+ const dirName = 'test_directory'
+
+ await sandbox.files.makeDir(dirName)
+ const exists = await sandbox.files.exists(dirName)
+ assert.isTrue(exists)
+})
+
+sandboxTest('make nested directory', async ({ sandbox }) => {
+ const nestedDirName = 'test_directory/nested_directory'
+
+ await sandbox.files.makeDir(nestedDirName)
+ const exists = await sandbox.files.exists(nestedDirName)
+ assert.isTrue(exists)
+})
diff --git a/packages/js-sdk/tests/sandbox/files/read.test.mts b/packages/js-sdk/tests/sandbox/files/read.test.mts
index e69de29bb..2eae6c2d4 100644
--- a/packages/js-sdk/tests/sandbox/files/read.test.mts
+++ b/packages/js-sdk/tests/sandbox/files/read.test.mts
@@ -0,0 +1,22 @@
+import { assert } from 'vitest'
+
+import { sandboxTest } from '../../setup.mjs'
+
+sandboxTest('read file', async ({ sandbox }) => {
+ const filename = 'test_read.txt'
+ const content = 'Hello, world!'
+
+ await sandbox.files.write(filename, content)
+ const readContent = await sandbox.files.read(filename)
+ assert.equal(readContent, content)
+})
+
+sandboxTest('read non-existing file', async ({ sandbox }) => {
+ const filename = 'non_existing_file.txt'
+
+ try {
+ await sandbox.files.read(filename)
+ } catch (error) {
+ assert.instanceOf(error, Error)
+ }
+})
diff --git a/packages/js-sdk/tests/sandbox/files/remove.test.mts b/packages/js-sdk/tests/sandbox/files/remove.test.mts
index e69de29bb..eabc02e7d 100644
--- a/packages/js-sdk/tests/sandbox/files/remove.test.mts
+++ b/packages/js-sdk/tests/sandbox/files/remove.test.mts
@@ -0,0 +1,23 @@
+import { assert } from 'vitest'
+
+import { sandboxTest } from '../../setup.mjs'
+
+sandboxTest('remove file', async ({ sandbox }) => {
+ const filename = 'test_remove.txt'
+ const content = 'This file will be removed.'
+
+ await sandbox.files.write(filename, content)
+ await sandbox.files.remove(filename)
+ const exists = await sandbox.files.exists(filename)
+ assert.isFalse(exists)
+})
+
+sandboxTest('remove non-existing file', async ({ sandbox }) => {
+ const filename = 'non_existing_file.txt'
+
+ try {
+ await sandbox.files.remove(filename)
+ } catch (error) {
+ assert.instanceOf(error, Error)
+ }
+})
diff --git a/packages/js-sdk/tests/sandbox/files/rename.test.mts b/packages/js-sdk/tests/sandbox/files/rename.test.mts
index e69de29bb..3c5420c77 100644
--- a/packages/js-sdk/tests/sandbox/files/rename.test.mts
+++ b/packages/js-sdk/tests/sandbox/files/rename.test.mts
@@ -0,0 +1,29 @@
+import { assert } from 'vitest'
+
+import { sandboxTest } from '../../setup.mjs'
+
+sandboxTest('rename file', async ({ sandbox }) => {
+ const oldFilename = 'test_rename_old.txt'
+ const newFilename = 'test_rename_new.txt'
+ const content = 'This file will be renamed.'
+
+ await sandbox.files.write(oldFilename, content)
+ await sandbox.files.rename(oldFilename, newFilename)
+ const existsOld = await sandbox.files.exists(oldFilename)
+ const existsNew = await sandbox.files.exists(newFilename)
+ assert.isFalse(existsOld)
+ assert.isTrue(existsNew)
+ const readContent = await sandbox.files.read(newFilename)
+ assert.equal(readContent, content)
+})
+
+sandboxTest('rename non-existing file', async ({ sandbox }) => {
+ const oldFilename = 'non_existing_file.txt'
+ const newFilename = 'new_non_existing_file.txt'
+
+ try {
+ await sandbox.files.rename(oldFilename, newFilename)
+ } catch (error) {
+ assert.instanceOf(error, Error)
+ }
+})
diff --git a/packages/js-sdk/tests/sandbox/files/watch.test.mts b/packages/js-sdk/tests/sandbox/files/watch.test.mts
index e69de29bb..c9f2daccf 100644
--- a/packages/js-sdk/tests/sandbox/files/watch.test.mts
+++ b/packages/js-sdk/tests/sandbox/files/watch.test.mts
@@ -0,0 +1,38 @@
+import { assert } from 'vitest'
+
+import { sandboxTest } from '../../setup.mjs'
+import { FilesystemEventType } from '../../../src'
+
+sandboxTest('watch directory changes', async ({ sandbox }) => {
+ const dirname = 'test_watch_dir'
+ const filename = 'test_watch.txt'
+ const content = 'This file will be watched.'
+ const newContent = 'This file has been modified.'
+
+ await sandbox.files.makeDir(dirname)
+ await sandbox.files.write(`${dirname}/${filename}`, content)
+
+ let eventTriggered = false
+ const handle = await sandbox.files.watch(dirname, async (event) => {
+ if (event.type === FilesystemEventType.WRITE && event.name === filename) {
+ eventTriggered = true
+ }
+ })
+
+ await sandbox.files.write(`${dirname}/${filename}`, newContent)
+ await new Promise(resolve => setTimeout(resolve, 1000)) // wait for the event to be triggered
+
+ assert.isTrue(eventTriggered)
+
+ await handle.close()
+})
+
+sandboxTest('watch non-existing directory', async ({ sandbox }) => {
+ const dirname = 'non_existing_watch_dir'
+
+ try {
+ await sandbox.files.watch(dirname, () => { })
+ } catch (error) {
+ assert.instanceOf(error, Error)
+ }
+})
diff --git a/packages/js-sdk/tests/sandbox/files/write.test.mts b/packages/js-sdk/tests/sandbox/files/write.test.mts
index e69de29bb..de0b69806 100644
--- a/packages/js-sdk/tests/sandbox/files/write.test.mts
+++ b/packages/js-sdk/tests/sandbox/files/write.test.mts
@@ -0,0 +1,36 @@
+import { assert } from 'vitest'
+
+import { sandboxTest } from '../../setup.mjs'
+
+sandboxTest('write file', async ({ sandbox }) => {
+ const filename = 'test_write.txt'
+ const content = 'This is a test file.'
+
+ await sandbox.files.write(filename, content)
+ const exists = await sandbox.files.exists(filename)
+ assert.isTrue(exists)
+ const readContent = await sandbox.files.read(filename)
+ assert.equal(readContent, content)
+})
+
+sandboxTest('overwrite file', async ({ sandbox }) => {
+ const filename = 'test_overwrite.txt'
+ const initialContent = 'Initial content.'
+ const newContent = 'New content.'
+
+ await sandbox.files.write(filename, initialContent)
+ await sandbox.files.write(filename, newContent)
+ const readContent = await sandbox.files.read(filename)
+ assert.equal(readContent, newContent)
+})
+
+sandboxTest('write to non-existing directory', async ({ sandbox }) => {
+ const filename = 'non_existing_dir/test_write.txt'
+ const content = 'This should fail.'
+
+ try {
+ await sandbox.files.write(filename, content)
+ } catch (error) {
+ assert.instanceOf(error, Error)
+ }
+})
diff --git a/packages/js-sdk/tests/sandbox/kill.test.mts b/packages/js-sdk/tests/sandbox/kill.test.mts
index e25978a0c..383cc94e4 100644
--- a/packages/js-sdk/tests/sandbox/kill.test.mts
+++ b/packages/js-sdk/tests/sandbox/kill.test.mts
@@ -1,8 +1,8 @@
import { assert } from 'vitest'
-import { sandboxTest } from '../setup.mjs'
+import { sandboxTest, isDebug } from '../setup.mjs'
-sandboxTest('kill', async ({ sandbox }) => {
+sandboxTest.skipIf(isDebug)('kill', async ({ sandbox }) => {
await sandbox.kill()
assert.throws(() => sandbox.isRunning())
diff --git a/packages/js-sdk/tests/setup.mts b/packages/js-sdk/tests/setup.mts
index 3c2a49685..8881fbd06 100644
--- a/packages/js-sdk/tests/setup.mts
+++ b/packages/js-sdk/tests/setup.mts
@@ -18,10 +18,14 @@ export const sandboxTest = base.extend<SandboxFixture>({
try {
await sandbox.kill()
} catch (err) {
- console.warn('Failed to kill sandbox — this is expected if the test runs with local envd.')
+ if (!isDebug) {
+ console.warn('Failed to kill sandbox — this is expected if the test runs with local envd.')
+ }
}
}
},
{ auto: true },
],
})
+
+export const isDebug = process.env.E2B_DEBUG !== undefined
diff --git a/packages/python-sdk/e2b/sandbox/process/process_handle.py b/packages/python-sdk/e2b/sandbox/process/process_handle.py
index 4ff5c1524..ecd7fbbfd 100644
--- a/packages/python-sdk/e2b/sandbox/process/process_handle.py
+++ b/packages/python-sdk/e2b/sandbox/process/process_handle.py
@@ -119,5 +119,4 @@ class ProcessHandle:
return self._result
def kill(self):
- self.disconnect()
self._handle_kill()
diff --git a/packages/python-sdk/pytest.ini b/packages/python-sdk/pytest.ini
new file mode 100644
index 000000000..3424fd4ab
--- /dev/null
+++ b/packages/python-sdk/pytest.ini
@@ -0,0 +1,4 @@
+# content of pytest.ini
+[pytest]
+markers =
+ skip_debug: skip test if E2B_DEBUG is set.
\ No newline at end of file
diff --git a/packages/python-sdk/tests/api/test_kill.py b/packages/python-sdk/tests/api/test_kill.py
index 5fc60e763..33c6c3cf7 100644
--- a/packages/python-sdk/tests/api/test_kill.py
+++ b/packages/python-sdk/tests/api/test_kill.py
@@ -1,14 +1,14 @@
-import os
import pytest
from e2b import Sandbox
[email protected](os.getenv("E2B_DEBUG") is not None)
def test_kill_existing_sandbox(sandbox: Sandbox):
Sandbox.kill(sandbox.sandbox_id)
def test_kill_non_existing_sandbox():
with pytest.raises(RuntimeError):
Sandbox.kill("non-existing-sandbox")
diff --git a/packages/python-sdk/tests/api/test_list.py b/packages/python-sdk/tests/api/test_list.py
index e69de29bb..91d8b19a3 100644
--- a/packages/python-sdk/tests/api/test_list.py
+++ b/packages/python-sdk/tests/api/test_list.py
@@ -0,0 +1,10 @@
+import pytest
+
+from e2b import Sandbox
+
+
+def test_list_sandboxes(sandbox: Sandbox):
+ sandboxes = Sandbox.list()
+ assert len(sandboxes) > 0
+ assert sandbox.sandbox_id in [sbx.sandbox_id for sbx in sandboxes]
diff --git a/packages/python-sdk/tests/conftest.py b/packages/python-sdk/tests/conftest.py
index 7da44913a..7d3992189 100644
--- a/packages/python-sdk/tests/conftest.py
+++ b/packages/python-sdk/tests/conftest.py
@@ -1,4 +1,5 @@
import pytest
+import os
from logging import warning
@@ -11,7 +12,7 @@ def template():
@pytest.fixture()
-def sandbox(template):
+def sandbox(template, debug):
sandbox = Sandbox(template)
try:
@@ -20,6 +21,19 @@ def sandbox(template):
try:
sandbox.kill()
except:
- warning(
- "Failed to kill sandbox — this is expected if the test runs with local envd."
- )
+ if not debug:
+ warning(
+ "Failed to kill sandbox — this is expected if the test runs with local envd."
+ )
+
+
+def debug():
+ return os.getenv("E2B_DEBUG") is not None
+
+
[email protected](autouse=True)
+def skip_by_debug(request, debug):
+ if request.node.get_closest_marker("skip_debug"):
+ if debug:
+ pytest.skip("skipped because E2B_DEBUG is set")
diff --git a/packages/python-sdk/tests/sandbox/test_connect.py b/packages/python-sdk/tests/sandbox/test_connect.py
index e69de29bb..10da75ca0 100644
--- a/packages/python-sdk/tests/sandbox/test_connect.py
+++ b/packages/python-sdk/tests/sandbox/test_connect.py
@@ -0,0 +1,9 @@
+from e2b.sandbox.main import Sandbox
+
+
+def test_connect(template):
+ sbx = Sandbox(template, timeout=10)
+ assert sbx.is_running()
+
+ sbx_connection = Sandbox.connect(sbx.sandbox_id)
+ assert sbx_connection.is_running()
diff --git a/packages/python-sdk/tests/sandbox/test_create.py b/packages/python-sdk/tests/sandbox/test_create.py
index 1e03818b4..8fbfdfe23 100644
--- a/packages/python-sdk/tests/sandbox/test_create.py
+++ b/packages/python-sdk/tests/sandbox/test_create.py
@@ -1,6 +1,9 @@
+import pytest
+
from e2b.sandbox.main import Sandbox
def test_start(template):
sbx = Sandbox(template, timeout=5)
assert sbx.is_running()
diff --git a/packages/python-sdk/tests/sandbox/test_kill.py b/packages/python-sdk/tests/sandbox/test_kill.py
index 5ba2b222c..e7b417df9 100644
--- a/packages/python-sdk/tests/sandbox/test_kill.py
+++ b/packages/python-sdk/tests/sandbox/test_kill.py
@@ -3,6 +3,7 @@ import pytest
from e2b.sandbox.main import Sandbox
def test_kill(sandbox: Sandbox):
sandbox.kill()
with pytest.raises(Exception):