Skip to content

Commit dc14e0f

Browse files
committed
added 1s delay after context create before list
1 parent c6eeca7 commit dc14e0f

File tree

3 files changed

+22
-2
lines changed

3 files changed

+22
-2
lines changed

js/tests/contexts.test.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ import { sandboxTest } from './setup'
55
sandboxTest('create context with no options', async ({ sandbox }) => {
66
const context = await sandbox.createCodeContext()
77

8+
// wait 1 second for the context to be created
9+
await new Promise((resolve) => setTimeout(resolve, 1000))
10+
811
const contexts = await sandbox.listCodeContexts()
912
const lastContext = contexts[contexts.length - 1]
1013

@@ -19,6 +22,9 @@ sandboxTest('create context with options', async ({ sandbox }) => {
1922
cwd: '/root',
2023
})
2124

25+
// wait 1 second for the context to be created
26+
await new Promise((resolve) => setTimeout(resolve, 1000))
27+
2228
const contexts = await sandbox.listCodeContexts()
2329
const lastContext = contexts[contexts.length - 1]
2430

python/tests/async/test_async_contexts.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
from e2b_code_interpreter.code_interpreter_async import AsyncSandbox
2+
import asyncio
23

34

45
async def test_create_context_with_no_options(async_sandbox: AsyncSandbox):
56
context = await async_sandbox.create_code_context()
67

8+
# wait 1 second for the context to be created
9+
await asyncio.sleep(1)
10+
711
contexts = await async_sandbox.list_code_contexts()
812
last_context = contexts[-1]
913

@@ -15,9 +19,12 @@ async def test_create_context_with_no_options(async_sandbox: AsyncSandbox):
1519
async def test_create_context_with_options(async_sandbox: AsyncSandbox):
1620
context = await async_sandbox.create_code_context(
1721
language="python",
18-
cwd="/home/user/test",
22+
cwd="/root",
1923
)
2024

25+
# wait 1 second for the context to be created
26+
await asyncio.sleep(1)
27+
2128
contexts = await async_sandbox.list_code_contexts()
2229
last_context = contexts[-1]
2330

python/tests/sync/test_contexts.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
from e2b_code_interpreter.code_interpreter_sync import Sandbox
2+
import time
23

34

45
def test_create_context_with_no_options(sandbox: Sandbox):
56
context = sandbox.create_code_context()
67

8+
# wait 1 second for the context to be created
9+
time.sleep(1)
10+
711
contexts = sandbox.list_code_contexts()
812
last_context = contexts[-1]
913

@@ -15,9 +19,12 @@ def test_create_context_with_no_options(sandbox: Sandbox):
1519
def test_create_context_with_options(sandbox: Sandbox):
1620
context = sandbox.create_code_context(
1721
language="python",
18-
cwd="/home/user/test",
22+
cwd="/root",
1923
)
2024

25+
# wait 1 second for the context to be created
26+
time.sleep(1)
27+
2128
contexts = sandbox.list_code_contexts()
2229
last_context = contexts[-1]
2330

0 commit comments

Comments
 (0)