-
Notifications
You must be signed in to change notification settings - Fork 207
Expand file tree
/
Copy pathtest_default_kernels.py
More file actions
49 lines (36 loc) · 1.36 KB
/
test_default_kernels.py
File metadata and controls
49 lines (36 loc) · 1.36 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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
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!"
def test_js_esm_imports(sandbox: Sandbox):
execution = sandbox.run_code(
"""
import { readFileSync } from 'fs'
console.log(typeof readFileSync)
""",
language="js",
)
assert execution.logs.stdout == ["function\n"]
def test_js_top_level_await(sandbox: Sandbox):
execution = sandbox.run_code(
"""
await Promise.resolve('Hello World!')
""",
language="js",
)
assert execution.text == "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"]