Skip to content

Commit 7b5053f

Browse files
committed
Add test for reconnect
1 parent 6c6156c commit 7b5053f

File tree

3 files changed

+29
-1
lines changed

3 files changed

+29
-1
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ with CodeInterpreter() as sandbox:
8989
result = sandbox.notebook.exec_cell(code)
9090

9191
# there's your image
92-
image = result.display_data[0]["image/png"]
92+
image = result.data[0].png
9393

9494
# example how to show the image / prove it works
9595
i = base64.b64decode(image)

js/tests/reconnect.test.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { CodeInterpreter } from '../src'
2+
3+
import { expect, test } from 'vitest'
4+
5+
test('reconnect', async () => {
6+
let sandbox = await CodeInterpreter.create()
7+
await sandbox.close()
8+
9+
sandbox = await CodeInterpreter.reconnect(sandbox.id)
10+
11+
const result = await sandbox.notebook.execCell('x =1; x')
12+
13+
expect(result.text).toEqual('1')
14+
15+
await sandbox.close()
16+
})

python/tests/test_reconnect.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
from e2b_code_interpreter.main import CodeInterpreter
2+
3+
4+
def test_basic():
5+
with CodeInterpreter() as sandbox:
6+
sandbox_id = sandbox.id
7+
8+
sandbox = CodeInterpreter.reconnect(sandbox_id)
9+
result = sandbox.notebook.exec_cell("x =1; x")
10+
assert result.text == "1"
11+
12+
sandbox.close()

0 commit comments

Comments
 (0)