From bd11a9838e006f913cf2bbf343722dc06558af82 Mon Sep 17 00:00:00 2001 From: Mish Ushakov <10400064+mishushakov@users.noreply.github.com> Date: Tue, 31 Mar 2026 22:17:55 +0200 Subject: [PATCH 1/3] added tests for pwd --- js/tests/cwd.test.ts | 50 ++++++++++++++++++++++++++++ python/tests/async/test_async_cwd.py | 41 +++++++++++++++++++++++ python/tests/sync/test_cwd.py | 39 ++++++++++++++++++++++ 3 files changed, 130 insertions(+) create mode 100644 js/tests/cwd.test.ts create mode 100644 python/tests/async/test_async_cwd.py create mode 100644 python/tests/sync/test_cwd.py diff --git a/js/tests/cwd.test.ts b/js/tests/cwd.test.ts new file mode 100644 index 00000000..9c67aace --- /dev/null +++ b/js/tests/cwd.test.ts @@ -0,0 +1,50 @@ +import { expect } from 'vitest' + +import { isDebug, sandboxTest } from './setup' + +// Skip these tests in debug mode — the pwd and user in the testing docker container +// are not the same as in the actual sandbox. + +sandboxTest.skipIf(isDebug)('cwd python', async ({ sandbox }) => { + const result = await sandbox.runCode( + 'from pathlib import Path; print(Path.cwd())', + { language: 'python' } + ) + expect(result.logs.stdout.join().trim()).toEqual('/home/user') +}) + +sandboxTest.skipIf(isDebug)('cwd javascript', async ({ sandbox }) => { + const result = await sandbox.runCode('process.cwd()', { + language: 'js', + }) + expect(result.text).toEqual('/home/user') +}) + +sandboxTest.skipIf(isDebug)('cwd typescript', async ({ sandbox }) => { + const result = await sandbox.runCode('process.cwd()', { + language: 'ts', + }) + expect(result.text).toEqual('/home/user') +}) + +sandboxTest.skipIf(isDebug)('cwd deno', async ({ sandbox }) => { + const result = await sandbox.runCode('Deno.cwd()', { + language: 'deno', + }) + expect(result.text).toEqual('/home/user') +}) + +sandboxTest.skipIf(isDebug)('cwd r', async ({ sandbox }) => { + const result = await sandbox.runCode('getwd()', { + language: 'r', + }) + expect(result.results[0]?.text.trim()).toEqual('[1] "/home/user"') +}) + +sandboxTest.skipIf(isDebug)('cwd java', async ({ sandbox }) => { + const result = await sandbox.runCode( + 'System.getProperty("user.dir")', + { language: 'java' } + ) + expect(result.results[0]?.text.trim()).toEqual('/home/user') +}) diff --git a/python/tests/async/test_async_cwd.py b/python/tests/async/test_async_cwd.py new file mode 100644 index 00000000..fd8f7847 --- /dev/null +++ b/python/tests/async/test_async_cwd.py @@ -0,0 +1,41 @@ +import pytest + +from e2b_code_interpreter.code_interpreter_async import AsyncSandbox + + +@pytest.mark.skip_debug() +async def test_cwd_python(async_sandbox: AsyncSandbox): + result = await async_sandbox.run_code("from pathlib import Path; print(Path.cwd())") + assert "".join(result.logs.stdout).strip() == "/home/user" + + +@pytest.mark.skip_debug() +async def test_cwd_javascript(async_sandbox: AsyncSandbox): + result = await async_sandbox.run_code("process.cwd()", language="js") + assert result.text == "/home/user" + + +@pytest.mark.skip_debug() +async def test_cwd_typescript(async_sandbox: AsyncSandbox): + result = await async_sandbox.run_code("process.cwd()", language="ts") + assert result.text == "/home/user" + + +@pytest.mark.skip_debug() +async def test_cwd_deno(async_sandbox: AsyncSandbox): + result = await async_sandbox.run_code("Deno.cwd()", language="deno") + assert result.text == "/home/user" + + +@pytest.mark.skip_debug() +async def test_cwd_r(async_sandbox: AsyncSandbox): + result = await async_sandbox.run_code("getwd()", language="r") + assert result.results[0].text.strip() == '[1] "/home/user"' + + +@pytest.mark.skip_debug() +async def test_cwd_java(async_sandbox: AsyncSandbox): + result = await async_sandbox.run_code( + 'System.getProperty("user.dir")', language="java" + ) + assert result.results[0].text.strip() == "/home/user" diff --git a/python/tests/sync/test_cwd.py b/python/tests/sync/test_cwd.py new file mode 100644 index 00000000..24d2e6ee --- /dev/null +++ b/python/tests/sync/test_cwd.py @@ -0,0 +1,39 @@ +import pytest + +from e2b_code_interpreter.code_interpreter_sync import Sandbox + + +@pytest.mark.skip_debug() +def test_cwd_python(sandbox: Sandbox): + result = sandbox.run_code("from pathlib import Path; print(Path.cwd())") + assert "".join(result.logs.stdout).strip() == "/home/user" + + +@pytest.mark.skip_debug() +def test_cwd_javascript(sandbox: Sandbox): + result = sandbox.run_code("process.cwd()", language="js") + assert result.text == "/home/user" + + +@pytest.mark.skip_debug() +def test_cwd_typescript(sandbox: Sandbox): + result = sandbox.run_code("process.cwd()", language="ts") + assert result.text == "/home/user" + + +@pytest.mark.skip_debug() +def test_cwd_deno(sandbox: Sandbox): + result = sandbox.run_code("Deno.cwd()", language="deno") + assert result.text == "/home/user" + + +@pytest.mark.skip_debug() +def test_cwd_r(sandbox: Sandbox): + result = sandbox.run_code("getwd()", language="r") + assert result.results[0].text.strip() == '[1] "/home/user"' + + +@pytest.mark.skip_debug() +def test_cwd_java(sandbox: Sandbox): + result = sandbox.run_code('System.getProperty("user.dir")', language="java") + assert result.results[0].text.strip() == "/home/user" From f371b2b056bbed8b8c2227262ebb25ae91346b07 Mon Sep 17 00:00:00 2001 From: Mish Ushakov <10400064+mishushakov@users.noreply.github.com> Date: Tue, 31 Mar 2026 22:20:29 +0200 Subject: [PATCH 2/3] fmt --- js/tests/cwd.test.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/js/tests/cwd.test.ts b/js/tests/cwd.test.ts index 9c67aace..d94107da 100644 --- a/js/tests/cwd.test.ts +++ b/js/tests/cwd.test.ts @@ -42,9 +42,8 @@ sandboxTest.skipIf(isDebug)('cwd r', async ({ sandbox }) => { }) sandboxTest.skipIf(isDebug)('cwd java', async ({ sandbox }) => { - const result = await sandbox.runCode( - 'System.getProperty("user.dir")', - { language: 'java' } - ) + const result = await sandbox.runCode('System.getProperty("user.dir")', { + language: 'java', + }) expect(result.results[0]?.text.trim()).toEqual('/home/user') }) From f53a2e26d56d88c6baf82c44622cf38a88fcd36b Mon Sep 17 00:00:00 2001 From: Mish Ushakov <10400064+mishushakov@users.noreply.github.com> Date: Tue, 31 Mar 2026 22:26:26 +0200 Subject: [PATCH 3/3] updated tests --- js/tests/cwd.test.ts | 7 ------- python/tests/async/test_async_cwd.py | 6 ------ python/tests/sync/test_cwd.py | 6 ------ 3 files changed, 19 deletions(-) diff --git a/js/tests/cwd.test.ts b/js/tests/cwd.test.ts index d94107da..b9a35ca3 100644 --- a/js/tests/cwd.test.ts +++ b/js/tests/cwd.test.ts @@ -27,13 +27,6 @@ sandboxTest.skipIf(isDebug)('cwd typescript', async ({ sandbox }) => { expect(result.text).toEqual('/home/user') }) -sandboxTest.skipIf(isDebug)('cwd deno', async ({ sandbox }) => { - const result = await sandbox.runCode('Deno.cwd()', { - language: 'deno', - }) - expect(result.text).toEqual('/home/user') -}) - sandboxTest.skipIf(isDebug)('cwd r', async ({ sandbox }) => { const result = await sandbox.runCode('getwd()', { language: 'r', diff --git a/python/tests/async/test_async_cwd.py b/python/tests/async/test_async_cwd.py index fd8f7847..e03b3e68 100644 --- a/python/tests/async/test_async_cwd.py +++ b/python/tests/async/test_async_cwd.py @@ -21,12 +21,6 @@ async def test_cwd_typescript(async_sandbox: AsyncSandbox): assert result.text == "/home/user" -@pytest.mark.skip_debug() -async def test_cwd_deno(async_sandbox: AsyncSandbox): - result = await async_sandbox.run_code("Deno.cwd()", language="deno") - assert result.text == "/home/user" - - @pytest.mark.skip_debug() async def test_cwd_r(async_sandbox: AsyncSandbox): result = await async_sandbox.run_code("getwd()", language="r") diff --git a/python/tests/sync/test_cwd.py b/python/tests/sync/test_cwd.py index 24d2e6ee..35f91a2b 100644 --- a/python/tests/sync/test_cwd.py +++ b/python/tests/sync/test_cwd.py @@ -21,12 +21,6 @@ def test_cwd_typescript(sandbox: Sandbox): assert result.text == "/home/user" -@pytest.mark.skip_debug() -def test_cwd_deno(sandbox: Sandbox): - result = sandbox.run_code("Deno.cwd()", language="deno") - assert result.text == "/home/user" - - @pytest.mark.skip_debug() def test_cwd_r(sandbox: Sandbox): result = sandbox.run_code("getwd()", language="r")