-
Notifications
You must be signed in to change notification settings - Fork 207
Expand file tree
/
Copy pathtest_default_kernels.py
More file actions
32 lines (21 loc) · 1.1 KB
/
test_default_kernels.py
File metadata and controls
32 lines (21 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import pytest
from e2b_code_interpreter.code_interpreter_sync import Sandbox
def test_js_kernel(sandbox: Sandbox):
execution = sandbox.run_code("console.log('Hello, World!')", language="js")
assert execution.logs.stdout == ["Hello, World!\n"]
@pytest.mark.skip_debug()
def test_r_kernel(sandbox: Sandbox):
execution = sandbox.run_code('print("Hello, World!")', language="r")
assert execution.logs.stdout == ['[1] "Hello, World!"\n']
@pytest.mark.skip_debug()
def test_java_kernel(sandbox: Sandbox):
execution = sandbox.run_code('System.out.println("Hello, World!")', language="java")
assert execution.logs.stdout[0] == "Hello, World!"
@pytest.mark.skip_debug()
def test_ts_kernel(sandbox: Sandbox):
execution = sandbox.run_code("const message: string = 'Hello, World!'; console.log(message)", language="ts")
assert execution.logs.stdout == ["Hello, World!\n"]
def test_ts_kernel_errors(sandbox: Sandbox):
execution = sandbox.run_code("import x from 'module';", language="ts")
assert execution.error is not None
assert execution.error.name == "TypeScriptCompilerError"