-
Notifications
You must be signed in to change notification settings - Fork 207
Expand file tree
/
Copy pathtest_async_default_kernels.py
More file actions
29 lines (22 loc) · 1 KB
/
test_async_default_kernels.py
File metadata and controls
29 lines (22 loc) · 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
from e2b_code_interpreter.code_interpreter_async import AsyncSandbox
async def test_js_kernel(async_sandbox: AsyncSandbox):
execution = await async_sandbox.run_code(
"console.log('Hello, World!')", language="js"
)
assert execution.logs.stdout == ["Hello, World!\n"]
async def test_js_esm_imports(async_sandbox: AsyncSandbox):
execution = await async_sandbox.run_code("""
import { readFileSync } from 'fs'
console.log(typeof readFileSync)
""", language="js")
assert execution.logs.stdout == ["function\n"]
async def test_js_top_level_await(async_sandbox: AsyncSandbox):
execution = await async_sandbox.run_code("""
await Promise.resolve('Hello World!')
""", language="js")
assert execution.text == "Hello World!"
async def test_ts_kernel(async_sandbox: AsyncSandbox):
execution = await async_sandbox.run_code(
"const message: string = 'Hello, World!'; console.log(message);", language="ts"
)
assert execution.logs.stdout == ["Hello, World!\n"]