Open-source, secure environment with real-world tools for enterprise-grade agents.
Python agentaiai-agentai-agentscode-interpretercopilotdevelopmentdevtoolsgptgpt-4javascriptllmnextjsopenaipythonreactsoftwaretypescript
Add tests for infra
Jakub Novak7a1830ebc385
diff --git a/packages/python-sdk/example.py b/packages/python-sdk/example.pyindex 0e7a1a2ab..c1178fa47 100644--- a/packages/python-sdk/example.py+++ b/packages/python-sdk/example.py@@ -2,23 +2,22 @@ import asyncioimport loggingfrom os import getenv-from e2b import Session, run_code+from e2b import Sessionid = "Python3"E2B_API_KEY = getenv("E2B_API_KEY")-logging.basicConfig(level=logging.ERROR)async def main():- # s = Session("Nodejs", api_key=E2B_API_KEY)- # await s.open()- # await s.close()+ s = Session("Nodejs", api_key=E2B_API_KEY)+ await s.open()- stdout, stderr = await run_code("Node16", "console.log('hello world'); throw new Error('error')")- print(stdout)- print(stderr)+ a = await s.process.start("ls -la /var ")+ await a+ print(a.stdout)+ print(a.stderr)returnsession = await Session.create(id)diff --git a/packages/python-sdk/tests/infra/test_install_package.py b/packages/python-sdk/tests/infra/test_install_package.pynew file mode 100644index 000000000..ad4a0cbb1--- /dev/null+++ b/packages/python-sdk/tests/infra/test_install_package.py@@ -0,0 +1,14 @@+from e2b import Session+++async def test_python_package():+ session = await Session.create("Python3")++ process = await session.process.start("pip install pip-install-test")+ await process++ process = await session.process.start('python -c "import pip_install_test"')+ await process+ output = process.stdout+ assert "Good job!" in output+ await session.close()diff --git a/packages/python-sdk/tests/infra/test_sudo.py b/packages/python-sdk/tests/infra/test_sudo.pyindex 0c2b39448..53e905503 100644--- a/packages/python-sdk/tests/infra/test_sudo.py+++ b/packages/python-sdk/tests/infra/test_sudo.py@@ -7,5 +7,5 @@ async def test_sudo():process = await session.process.start("sudo echo test")await processoutput = process.stdout- assert output == "/home/user"+ assert output == "test"await session.close()