E2B/packages/python-sdk/tests/test_run_code.py
Jakub Novák 388309830b
New infra (#212)
Co-authored-by: Tomas Valenta <valenta.and.thomas@gmail.com>
Co-authored-by: Vasek Mlejnsky <vasek.mlejnsky@gmail.com>
2023-11-06 15:07:09 +01:00

19 lines
501 B
Python

import pytest
from e2b import run_code
from e2b.sandbox.exception import UnsupportedRuntimeException
def test_run_code():
code = "console.log('hello\\n'.repeat(10)); throw new Error('error')"
stdout, stderr = run_code("Node16", code)
assert len(stdout) == 60
assert "Error: error" in stderr
def test_unsupported_runtime():
code = "console.log('hello'); throw new Error('error')"
with pytest.raises(UnsupportedRuntimeException) as e:
run_code("unsupported", code)