forked from e2b-dev/code-interpreter
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_kernels.py
More file actions
23 lines (15 loc) · 718 Bytes
/
test_kernels.py
File metadata and controls
23 lines (15 loc) · 718 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import pytest
from e2b import InvalidArgumentException
from e2b_code_interpreter.code_interpreter_sync import Sandbox
def test_create_new_kernel(sandbox: Sandbox):
sandbox.create_code_context()
def test_independence_of_kernels(sandbox: Sandbox):
context = sandbox.create_code_context()
sandbox.run_code("x = 1")
r = sandbox.run_code("x", context=context)
assert r.error is not None
assert r.error.value == "name 'x' is not defined"
def test_pass_context_and_language(sandbox: Sandbox):
context = sandbox.create_code_context(language="python")
with pytest.raises(InvalidArgumentException):
sandbox.run_code("console.log('Hello, World!')", language="js", context=context)