Skip to content

armgit / E2B

Public Imported from GitHub
0

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

Fixes ubuntu default image tag and added tests (#982)

Mish Ushakovd4619f641b89
diff --git a/.changeset/dry-lions-speak.md b/.changeset/dry-lions-speak.md
new file mode 100644
index 000000000..fe0d78593
--- /dev/null
+++ b/.changeset/dry-lions-speak.md
@@ -0,0 +1,6 @@
+---
+'@e2b/python-sdk': patch
+'e2b': patch
+---
+
+fix from ubuntu default variant
diff --git a/packages/js-sdk/src/template/index.ts b/packages/js-sdk/src/template/index.ts
index c106e0ecc..9fdee6150 100644
--- a/packages/js-sdk/src/template/index.ts
+++ b/packages/js-sdk/src/template/index.ts
@@ -126,7 +126,7 @@ export class TemplateBase
return this.fromImage(`debian:${variant}`)
}
- fromUbuntuImage(variant: string = 'lts'): TemplateBuilder {
+ fromUbuntuImage(variant: string = 'latest'): TemplateBuilder {
return this.fromImage(`ubuntu:${variant}`)
}
diff --git a/packages/js-sdk/src/template/types.ts b/packages/js-sdk/src/template/types.ts
index a56a5441b..3ce05faac 100644
--- a/packages/js-sdk/src/template/types.ts
+++ b/packages/js-sdk/src/template/types.ts
@@ -119,7 +119,7 @@ export interface TemplateFromImage {
/**
* Start from an Ubuntu-based Docker image.
- * @param variant Ubuntu variant (default: 'lts')
+ * @param variant Ubuntu variant (default: 'latest')
*
* @example
* ```ts
diff --git a/packages/js-sdk/tests/template/build.test.ts b/packages/js-sdk/tests/template/build.test.ts
index c4580e4fb..6a661227d 100644
--- a/packages/js-sdk/tests/template/build.test.ts
+++ b/packages/js-sdk/tests/template/build.test.ts
@@ -27,37 +27,28 @@ afterAll(() => {
fs.rmSync(folderPath, { recursive: true })
})
-buildTemplateTest(
- 'build template',
- { timeout: 180000 },
- async ({ buildTemplate }) => {
- const template = Template()
- .fromImage('ubuntu:22.04')
- .copy('folder/*', 'folder', { forceUpload: true })
- .runCmd('cat folder/test.txt')
- .setWorkdir('/app')
- .setStartCmd('echo "Hello, world!"', waitForTimeout(10_000))
+buildTemplateTest('build template', async ({ buildTemplate }) => {
+ const template = Template()
+ .fromImage('ubuntu:22.04')
+ .copy('folder/*', 'folder', { forceUpload: true })
+ .runCmd('cat folder/test.txt')
+ .setWorkdir('/app')
+ .setStartCmd('echo "Hello, world!"', waitForTimeout(10_000))
- await buildTemplate(template, undefined, defaultBuildLogger())
- }
-)
+ await buildTemplate(template, undefined, defaultBuildLogger())
+})
-buildTemplateTest(
- 'build template with symlinks',
- { timeout: 180000 },
- async ({ buildTemplate }) => {
- const template = Template()
- .fromImage('ubuntu:22.04')
- .copy('folder/*', 'folder', { forceUpload: true })
- .runCmd('cat folder/symlink.txt')
+buildTemplateTest('build template with symlinks', async ({ buildTemplate }) => {
+ const template = Template()
+ .fromImage('ubuntu:22.04')
+ .copy('folder/*', 'folder', { forceUpload: true })
+ .runCmd('cat folder/symlink.txt')
- await buildTemplate(template)
- }
-)
+ await buildTemplate(template)
+})
buildTemplateTest(
'build template with resolveSymlinks',
- { timeout: 180000 },
async ({ buildTemplate }) => {
const template = Template()
.fromImage('ubuntu:22.04')
@@ -73,7 +64,6 @@ buildTemplateTest(
buildTemplateTest(
'build template with skipCache',
- { timeout: 180000 },
async ({ buildTemplate }) => {
const template = Template().skipCache().fromImage('ubuntu:22.04')
await buildTemplate(template)
diff --git a/packages/js-sdk/tests/template/methods/fromMethods.test.ts b/packages/js-sdk/tests/template/methods/fromMethods.test.ts
new file mode 100644
index 000000000..3abd3c24a
--- /dev/null
+++ b/packages/js-sdk/tests/template/methods/fromMethods.test.ts
@@ -0,0 +1,85 @@
+import { buildTemplateTest } from '../../setup'
+import { Template } from '../../../src'
+import path from 'node:path'
+import fs from 'node:fs'
+import { afterAll, beforeAll } from 'vitest'
+
+const fileContextPath = path.join(__dirname, 'dockerfile-context')
+
+beforeAll(async () => {
+ fs.mkdirSync(fileContextPath, { recursive: true })
+ fs.writeFileSync(
+ path.join(fileContextPath, 'package.json'),
+ JSON.stringify({ name: 'my-app', version: '1.0.0' }, null, 2),
+ 'utf-8'
+ )
+})
+
+afterAll(async () => {
+ fs.rmSync(fileContextPath, { recursive: true, force: true })
+})
+
+buildTemplateTest('fromBaseImage', async ({ buildTemplate }) => {
+ const template = Template().fromBaseImage()
+ await buildTemplate(template)
+})
+
+buildTemplateTest('fromDebianImage', async ({ buildTemplate }) => {
+ const template = Template().fromDebianImage()
+ await buildTemplate(template)
+})
+
+buildTemplateTest('fromDebianImage with variant', async ({ buildTemplate }) => {
+ const template = Template().fromDebianImage('bookworm')
+ await buildTemplate(template)
+})
+
+buildTemplateTest('fromUbuntuImage', async ({ buildTemplate }) => {
+ const template = Template().fromUbuntuImage()
+ await buildTemplate(template)
+})
+
+buildTemplateTest('fromUbuntuImage with variant', async ({ buildTemplate }) => {
+ const template = Template().fromUbuntuImage('24.04')
+ await buildTemplate(template)
+})
+
+buildTemplateTest('fromPythonImage', async ({ buildTemplate }) => {
+ const template = Template().fromPythonImage()
+ await buildTemplate(template)
+})
+
+buildTemplateTest('fromPythonImage with variant', async ({ buildTemplate }) => {
+ const template = Template().fromPythonImage('3.12')
+ await buildTemplate(template)
+})
+
+buildTemplateTest('fromNodeImage', async ({ buildTemplate }) => {
+ const template = Template().fromNodeImage()
+ await buildTemplate(template)
+})
+
+buildTemplateTest('fromNodeImage with variant', async ({ buildTemplate }) => {
+ const template = Template().fromNodeImage('24')
+ await buildTemplate(template)
+})
+
+buildTemplateTest('fromImage', async ({ buildTemplate }) => {
+ const template = Template().fromImage('ubuntu:22.04')
+ await buildTemplate(template)
+})
+
+buildTemplateTest('fromTemplate', async ({ buildTemplate }) => {
+ const template = Template().fromTemplate('base')
+ await buildTemplate(template)
+})
+
+buildTemplateTest('fromDockerfile', async ({ buildTemplate }) => {
+ const dockerfile = `FROM node:24
+WORKDIR /app
+COPY package.json .
+RUN npm install`
+
+ const template = Template({ fileContextPath }).fromDockerfile(dockerfile)
+ await buildTemplate(template)
+})
diff --git a/packages/js-sdk/tests/template/methods/npmInstall.test.ts b/packages/js-sdk/tests/template/methods/npmInstall.test.ts
index 42a3fe16c..cbebffc0b 100644
--- a/packages/js-sdk/tests/template/methods/npmInstall.test.ts
+++ b/packages/js-sdk/tests/template/methods/npmInstall.test.ts
@@ -2,7 +2,7 @@ import { randomUUID } from 'node:crypto'
import { test } from 'vitest'
import { Template } from '../../../src'
-test('npm install', { timeout: 180000 }, async () => {
+test('npm install', async () => {
const template = Template().fromNodeImage('24').npmInstall(['lodash', 'ms'])
await Template.build(template, {
@@ -10,7 +10,7 @@ test('npm install', { timeout: 180000 }, async () => {
})
})
-test('npm install global', { timeout: 180000 }, async () => {
+test('npm install global', async () => {
const template = Template()
.fromNodeImage('24')
.npmInstall(['lodash', 'ms'], { g: true })
diff --git a/packages/js-sdk/tests/template/methods/pipInstall.test.ts b/packages/js-sdk/tests/template/methods/pipInstall.test.ts
index a9dd7f30f..074c66ef4 100644
--- a/packages/js-sdk/tests/template/methods/pipInstall.test.ts
+++ b/packages/js-sdk/tests/template/methods/pipInstall.test.ts
@@ -1,23 +1,18 @@
-import { randomUUID } from 'node:crypto'
-import { test } from 'vitest'
import { Template } from '../../../src'
+import { buildTemplateTest } from '../../setup'
-test('pip install', { timeout: 180000 }, async () => {
+buildTemplateTest('pip install', async ({ buildTemplate }) => {
const template = Template()
.fromPythonImage('3.13.7-trixie')
.pipInstall(['six', 'pyyaml'])
- await Template.build(template, {
- alias: randomUUID(),
- })
+ await buildTemplate(template)
})
-test('pip install global', { timeout: 180000 }, async () => {
+buildTemplateTest('pip install (user)', async ({ buildTemplate }) => {
const template = Template()
.fromPythonImage('3.13.7-trixie')
- .pipInstall(['six', 'pyyaml'], { g: true })
+ .pipInstall(['six', 'pyyaml'], { g: false })
- await Template.build(template, {
- alias: randomUUID(),
- })
+ await buildTemplate(template)
})
diff --git a/packages/js-sdk/tests/template/methods/runCmd.test.ts b/packages/js-sdk/tests/template/methods/runCmd.test.ts
index 549d19c45..ca4cdc002 100644
--- a/packages/js-sdk/tests/template/methods/runCmd.test.ts
+++ b/packages/js-sdk/tests/template/methods/runCmd.test.ts
@@ -1,38 +1,32 @@
-import { randomUUID } from 'node:crypto'
-import { expect, test } from 'vitest'
+import { expect } from 'vitest'
import { Template } from '../../../src'
+import { buildTemplateTest } from '../../setup'
-test('run command', { timeout: 180000 }, async () => {
+buildTemplateTest('run command', async ({ buildTemplate }) => {
const template = Template().fromImage('ubuntu:22.04').runCmd('ls -l')
- await Template.build(template, {
- alias: randomUUID(),
- })
+ await buildTemplate(template)
})
-test('run command as a different user', { timeout: 180000 }, async () => {
- const template = Template()
- .fromImage('ubuntu:22.04')
- .runCmd('test "$(whoami)" = "root"', { user: 'root' })
+buildTemplateTest(
+ 'run command as a different user',
+ async ({ buildTemplate }) => {
+ const template = Template()
+ .fromImage('ubuntu:22.04')
+ .runCmd('test "$(whoami)" = "root"', { user: 'root' })
- await Template.build(template, {
- alias: randomUUID(),
- })
-})
+ await buildTemplate(template)
+ }
+)
-test(
+buildTemplateTest(
'run command as user that does not exist',
- { timeout: 180000 },
- async () => {
+ async ({ buildTemplate }) => {
const template = Template()
.fromImage('ubuntu:22.04')
.runCmd('whoami', { user: 'root123' })
- await expect(
- Template.build(template, {
- alias: randomUUID(),
- })
- ).rejects.toThrow(
+ await expect(buildTemplate(template)).rejects.toThrow(
"failed to run command 'whoami': command failed: unauthenticated: invalid username: 'root123'"
)
}
diff --git a/packages/js-sdk/vitest.workspace.mts b/packages/js-sdk/vitest.workspace.mts
index 3cf9cd16c..0340881ac 100644
--- a/packages/js-sdk/vitest.workspace.mts
+++ b/packages/js-sdk/vitest.workspace.mts
@@ -6,7 +6,12 @@ export default defineWorkspace([
{
test: {
include: ['tests/**/*.test.ts'],
- exclude: ['tests/runtimes/**', 'tests/integration/**', 'tests/connectionConfig.test.ts'],
+ exclude: [
+ 'tests/runtimes/**',
+ 'tests/integration/**',
+ 'tests/template/**',
+ 'tests/connectionConfig.test.ts',
+ ],
isolate: false, // for projects that don't rely on side effects, disabling isolation will improve the speed of the tests
globals: false,
testTimeout: 30_000,
@@ -55,7 +60,7 @@ export default defineWorkspace([
},
{
test: {
- include: ['tests/template/stacktrace.test.ts'],
+ include: ['tests/template/**/*.test.ts'],
globals: false,
testTimeout: 180_000,
environment: 'node',
diff --git a/packages/python-sdk/e2b/template/main.py b/packages/python-sdk/e2b/template/main.py
index 4735bed9a..06a478489 100644
--- a/packages/python-sdk/e2b/template/main.py
+++ b/packages/python-sdk/e2b/template/main.py
@@ -775,11 +775,11 @@ class TemplateBase:
lambda: self.from_image(f"debian:{variant}")
)
- def from_ubuntu_image(self, variant: str = "lts") -> TemplateBuilder:
+ def from_ubuntu_image(self, variant: str = "latest") -> TemplateBuilder:
"""
Start template from an Ubuntu base image.
- :param variant: Ubuntu image variant (default: 'lts')
+ :param variant: Ubuntu image variant (default: 'latest')
:return: `TemplateBuilder` class
diff --git a/packages/python-sdk/tests/async/template_async/methods/test_from_methods.py b/packages/python-sdk/tests/async/template_async/methods/test_from_methods.py
new file mode 100644
index 000000000..60507b9bc
--- /dev/null
+++ b/packages/python-sdk/tests/async/template_async/methods/test_from_methods.py
@@ -0,0 +1,101 @@
+import tempfile
+import os
+import shutil
+import json
+
+import pytest
+
+from e2b import AsyncTemplate
+
+
[email protected](scope="module")
+def setup_dockerfile_context():
+ """Setup test directory with package.json for dockerfile context tests"""
+ test_dir = tempfile.mkdtemp(prefix="python_async_dockerfile_test_")
+
+ with open(os.path.join(test_dir, "package.json"), "w") as f:
+ json.dump({"name": "my-app", "version": "1.0.0"}, f, indent=2)
+
+ yield test_dir
+
+ # Cleanup
+ shutil.rmtree(test_dir, ignore_errors=True)
+
+
+async def test_from_base_image(async_build):
+ template = AsyncTemplate().from_base_image()
+ await async_build(template)
+
+
+async def test_from_debian_image(async_build):
+ template = AsyncTemplate().from_debian_image()
+ await async_build(template)
+
+
+async def test_from_debian_image_with_variant(async_build):
+ template = AsyncTemplate().from_debian_image("bookworm")
+ await async_build(template)
+
+
+async def test_from_ubuntu_image(async_build):
+ template = AsyncTemplate().from_ubuntu_image()
+ await async_build(template)
+
+
+async def test_from_ubuntu_image_with_variant(async_build):
+ template = AsyncTemplate().from_ubuntu_image("24.04")
+ await async_build(template)
+
+
+async def test_from_python_image(async_build):
+ template = AsyncTemplate().from_python_image()
+ await async_build(template)
+
+
+async def test_from_python_image_with_variant(async_build):
+ template = AsyncTemplate().from_python_image("3.12")
+ await async_build(template)
+
+
+async def test_from_node_image(async_build):
+ template = AsyncTemplate().from_node_image()
+ await async_build(template)
+
+
+async def test_from_node_image_with_variant(async_build):
+ template = AsyncTemplate().from_node_image("24")
+ await async_build(template)
+
+
+async def test_from_image(async_build):
+ template = AsyncTemplate().from_image("ubuntu:22.04")
+ await async_build(template)
+
+
+async def test_from_template(async_build):
+ template = AsyncTemplate().from_template("base")
+ await async_build(template)
+
+
+async def test_from_dockerfile(async_build, setup_dockerfile_context):
+ dockerfile = """FROM node:24
+WORKDIR /app
+COPY package.json .
+RUN npm install"""
+
+ template = AsyncTemplate(
+ file_context_path=setup_dockerfile_context
+ ).from_dockerfile(dockerfile)
+ await async_build(template)
diff --git a/packages/python-sdk/tests/async/template_async/methods/test_npm_install.py b/packages/python-sdk/tests/async/template_async/methods/test_npm_install.py
index 3eb9904e3..3d4e296e5 100644
--- a/packages/python-sdk/tests/async/template_async/methods/test_npm_install.py
+++ b/packages/python-sdk/tests/async/template_async/methods/test_npm_install.py
@@ -1,26 +1,19 @@
import pytest
-from uuid import uuid4
from e2b import AsyncTemplate
@pytest.mark.skip_debug()
-async def test_npm_install():
+async def test_npm_install(async_build):
template = AsyncTemplate().from_node_image("24").npm_install(["lodash", "ms"])
- await AsyncTemplate.build(
- template,
- alias=str(uuid4()),
- )
+ await async_build(template)
@pytest.mark.skip_debug()
-async def test_npm_install_global():
+async def test_npm_install_global(async_build):
template = (
AsyncTemplate().from_node_image("24").npm_install(["lodash", "ms"], g=True)
)
- await AsyncTemplate.build(
- template,
- alias=str(uuid4()),
- )
+ await async_build(template)
diff --git a/packages/python-sdk/tests/async/template_async/methods/test_pip_install.py b/packages/python-sdk/tests/async/template_async/methods/test_pip_install.py
index 392031bad..78db16253 100644
--- a/packages/python-sdk/tests/async/template_async/methods/test_pip_install.py
+++ b/packages/python-sdk/tests/async/template_async/methods/test_pip_install.py
@@ -1,32 +1,25 @@
import pytest
-from uuid import uuid4
from e2b import AsyncTemplate
@pytest.mark.skip_debug()
-async def test_pip_install():
+async def test_pip_install(async_build):
template = (
AsyncTemplate()
.from_python_image("3.13.7-trixie")
.pip_install(["six", "pyyaml"])
)
- await AsyncTemplate.build(
- template,
- alias=str(uuid4()),
- )
+ await async_build(template)
@pytest.mark.skip_debug()
-async def test_pip_install_global():
+async def test_pip_install_user(async_build):
template = (
AsyncTemplate()
.from_python_image("3.13.7-trixie")
- .pip_install(["six", "pyyaml"], g=True)
+ .pip_install(["six", "pyyaml"], g=False)
)
- await AsyncTemplate.build(
- template,
- alias=str(uuid4()),
- )
+ await async_build(template)
diff --git a/packages/python-sdk/tests/async/template_async/methods/test_run_cmd.py b/packages/python-sdk/tests/async/template_async/methods/test_run_cmd.py
index e71aaba21..d17b4e915 100644
--- a/packages/python-sdk/tests/async/template_async/methods/test_run_cmd.py
+++ b/packages/python-sdk/tests/async/template_async/methods/test_run_cmd.py
@@ -1,44 +1,34 @@
import pytest
-from uuid import uuid4
from e2b import AsyncTemplate
@pytest.mark.skip_debug()
-async def test_run_command():
+async def test_run_command(async_build):
template = AsyncTemplate().from_image("ubuntu:22.04").run_cmd("ls -l")
- await AsyncTemplate.build(
- template,
- alias=str(uuid4()),
- )
+ await async_build(template)
@pytest.mark.skip_debug()
-async def test_run_command_as_different_user():
+async def test_run_command_as_different_user(async_build):
template = (
AsyncTemplate()
.from_image("ubuntu:22.04")
.run_cmd('test "$(whoami)" = "root"', user="root")
)
- await AsyncTemplate.build(
- template,
- alias=str(uuid4()),
- )
+ await async_build(template)
@pytest.mark.skip_debug()
-async def test_run_command_as_user_that_does_not_exist():
+async def test_run_command_as_user_that_does_not_exist(async_build):
template = (
AsyncTemplate().from_image("ubuntu:22.04").run_cmd("whoami", user="root123")
)
with pytest.raises(Exception) as exc_info:
- await AsyncTemplate.build(
- template,
- alias=str(uuid4()),
- )
+ await async_build(template)
assert (
"failed to run command 'whoami': command failed: unauthenticated: invalid username: 'root123'"
diff --git a/packages/python-sdk/tests/sync/template_sync/methods/test_from_methods.py b/packages/python-sdk/tests/sync/template_sync/methods/test_from_methods.py
new file mode 100644
index 000000000..58759dfe2
--- /dev/null
+++ b/packages/python-sdk/tests/sync/template_sync/methods/test_from_methods.py
@@ -0,0 +1,102 @@
+import tempfile
+import os
+import shutil
+import json
+
+import pytest
+
+from e2b import Template
+
+
[email protected](scope="module")
+def setup_dockerfile_context():
+ """Setup test directory with package.json for dockerfile context tests"""
+ test_dir = tempfile.mkdtemp(prefix="python_sync_dockerfile_test_")
+
+ os.makedirs(test_dir, exist_ok=True)
+ with open(os.path.join(test_dir, "package.json"), "w") as f:
+ json.dump({"name": "my-app", "version": "1.0.0"}, f, indent=2)
+
+ yield test_dir
+
+ # Cleanup
+ shutil.rmtree(test_dir, ignore_errors=True)
+
+
+def test_from_base_image(build):
+ template = Template().from_base_image()
+ build(template)
+
+
+def test_from_debian_image(build):
+ template = Template().from_debian_image()
+ build(template)
+
+
+def test_from_debian_image_with_variant(build):
+ template = Template().from_debian_image("bookworm")
+ build(template)
+
+
+def test_from_ubuntu_image(build):
+ template = Template().from_ubuntu_image()
+ build(template)
+
+
+def test_from_ubuntu_image_with_variant(build):
+ template = Template().from_ubuntu_image("24.04")
+ build(template)
+
+
+def test_from_python_image(build):
+ template = Template().from_python_image()
+ build(template)
+
+
+def test_from_python_image_with_variant(build):
+ template = Template().from_python_image("3.12")
+ build(template)
+
+
+def test_from_node_image(build):
+ template = Template().from_node_image()
+ build(template)
+
+
+def test_from_node_image_with_variant(build):
+ template = Template().from_node_image("24")
+ build(template)
+
+
+def test_from_image(build):
+ template = Template().from_image("ubuntu:22.04")
+ build(template)
+
+
+def test_from_template(build):
+ template = Template().from_template("base")
+ build(template)
+
+
+def test_from_dockerfile(build, setup_dockerfile_context):
+ dockerfile = """FROM node:24
+WORKDIR /app
+COPY package.json .
+RUN npm install"""
+
+ template = Template(file_context_path=setup_dockerfile_context).from_dockerfile(
+ dockerfile
+ )
+ build(template)
diff --git a/packages/python-sdk/tests/sync/template_sync/methods/test_npm_install.py b/packages/python-sdk/tests/sync/template_sync/methods/test_npm_install.py
index 37ecd0eeb..e4ca45b35 100644
--- a/packages/python-sdk/tests/sync/template_sync/methods/test_npm_install.py
+++ b/packages/python-sdk/tests/sync/template_sync/methods/test_npm_install.py
@@ -1,24 +1,17 @@
import pytest
-from uuid import uuid4
from e2b import Template
@pytest.mark.skip_debug()
-def test_npm_install():
+def test_npm_install(build):
template = Template().from_node_image("24").npm_install(["lodash", "ms"])
- Template.build(
- template,
- alias=str(uuid4()),
- )
+ build(template)
@pytest.mark.skip_debug()
-def test_npm_install_global():
+def test_npm_install_global(build):
template = Template().from_node_image("24").npm_install(["lodash", "ms"], g=True)
- Template.build(
- template,
- alias=str(uuid4()),
- )
+ build(template)
diff --git a/packages/python-sdk/tests/sync/template_sync/methods/test_pip_install.py b/packages/python-sdk/tests/sync/template_sync/methods/test_pip_install.py
index 553b79785..e40c80450 100644
--- a/packages/python-sdk/tests/sync/template_sync/methods/test_pip_install.py
+++ b/packages/python-sdk/tests/sync/template_sync/methods/test_pip_install.py
@@ -1,16 +1,23 @@
import pytest
-from uuid import uuid4
from e2b import Template
@pytest.mark.skip_debug()
-def test_pip_install():
+def test_pip_install(build):
template = (
Template().from_python_image("3.13.7-trixie").pip_install(["six", "pyyaml"])
)
- Template.build(
- template,
- alias=str(uuid4()),
+ build(template)
+
+
+def test_pip_install_user(build):
+ template = (
+ Template()
+ .from_python_image("3.13.7-trixie")
+ .pip_install(["six", "pyyaml"], g=False)
)
+
+ build(template)
diff --git a/packages/python-sdk/tests/sync/template_sync/methods/test_run_cmd.py b/packages/python-sdk/tests/sync/template_sync/methods/test_run_cmd.py
index 8e5228e8f..9238ffe75 100644
--- a/packages/python-sdk/tests/sync/template_sync/methods/test_run_cmd.py
+++ b/packages/python-sdk/tests/sync/template_sync/methods/test_run_cmd.py
@@ -1,42 +1,32 @@
import pytest
-from uuid import uuid4
from e2b import Template
@pytest.mark.skip_debug()
-def test_run_command():
+def test_run_command(build):
template = Template().from_image("ubuntu:22.04").run_cmd("ls -l")
- Template.build(
- template,
- alias=str(uuid4()),
- )
+ build(template)
@pytest.mark.skip_debug()
-def test_run_command_as_different_user():
+def test_run_command_as_different_user(build):
template = (
Template()
.from_image("ubuntu:22.04")
.run_cmd('test "$(whoami)" = "root"', user="root")
)
- Template.build(
- template,
- alias=str(uuid4()),
- )
+ build(template)
@pytest.mark.skip_debug()
-def test_run_command_as_user_that_does_not_exist():
+def test_run_command_as_user_that_does_not_exist(build):
template = Template().from_image("ubuntu:22.04").run_cmd("whoami", user="root123")
with pytest.raises(Exception) as exc_info:
- Template.build(
- template,
- alias=str(uuid4()),
- )
+ build(template)
assert (
"failed to run command 'whoami': command failed: unauthenticated: invalid username: 'root123'"