Skip to content

Commit abe6a02

Browse files
committed
bugbot suggestions
1 parent d7b83b1 commit abe6a02

File tree

5 files changed

+22
-16
lines changed

5 files changed

+22
-16
lines changed

python/tests/async/test_async_basic.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@ async def test_basic(async_sandbox: AsyncSandbox):
1111
@pytest.mark.skip_debug
1212
async def test_secure_access(async_sandbox_factory):
1313
# Create sandbox with public traffic disabled (secure access)
14-
async_sandbox = async_sandbox_factory(network={"allow_public_traffic": False})
14+
async_sandbox = await async_sandbox_factory(network={"allow_public_traffic": False})
1515
result = await async_sandbox.run_code("x =1; x")
1616
assert result.text == "1"

python/tests/async/test_async_contexts.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ async def test_restart_context(async_sandbox: AsyncSandbox):
6666

6767
@pytest.mark.skip_debug
6868
async def test_create_context_secure_traffic(async_sandbox_factory):
69-
async_sandbox = async_sandbox_factory(network={"allow_public_traffic": False})
69+
async_sandbox = await async_sandbox_factory(network={"allow_public_traffic": False})
7070
context = await async_sandbox.create_code_context()
7171

7272
contexts = await async_sandbox.list_code_contexts()
@@ -79,7 +79,7 @@ async def test_create_context_secure_traffic(async_sandbox_factory):
7979

8080
@pytest.mark.skip_debug
8181
async def test_remove_context_secure_traffic(async_sandbox_factory):
82-
async_sandbox = async_sandbox_factory(network={"allow_public_traffic": False})
82+
async_sandbox = await async_sandbox_factory(network={"allow_public_traffic": False})
8383
context = await async_sandbox.create_code_context()
8484

8585
await async_sandbox.remove_code_context(context.id)
@@ -90,7 +90,7 @@ async def test_remove_context_secure_traffic(async_sandbox_factory):
9090

9191
@pytest.mark.skip_debug
9292
async def test_list_contexts_secure_traffic(async_sandbox_factory):
93-
async_sandbox = async_sandbox_factory(network={"allow_public_traffic": False})
93+
async_sandbox = await async_sandbox_factory(network={"allow_public_traffic": False})
9494
contexts = await async_sandbox.list_code_contexts()
9595

9696
# default contexts should include python and javascript
@@ -101,7 +101,7 @@ async def test_list_contexts_secure_traffic(async_sandbox_factory):
101101

102102
@pytest.mark.skip_debug
103103
async def test_restart_context_secure_traffic(async_sandbox_factory):
104-
async_sandbox = async_sandbox_factory(network={"allow_public_traffic": False})
104+
async_sandbox = await async_sandbox_factory(network={"allow_public_traffic": False})
105105
context = await async_sandbox.create_code_context()
106106

107107
# set a variable in the context

python/tests/conftest.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@ async def factory(template_override=None, **kwargs):
5353
template_name = template_override or template
5454
kwargs.setdefault("timeout", timeout)
5555
kwargs.setdefault("debug", debug)
56-
sandbox = await AsyncSandbox.create(template_name, network=network, **kwargs)
56+
kwargs.setdefault("network", network)
57+
sandbox = await AsyncSandbox.create(template_name, **kwargs)
5758

5859
def kill():
5960
async def _kill():
@@ -84,6 +85,11 @@ def debug():
8485
return os.getenv("E2B_DEBUG") is not None
8586

8687

88+
@pytest.fixture
89+
def network():
90+
return None
91+
92+
8793
@pytest.fixture(autouse=True)
8894
def skip_by_debug(request, debug):
8995
if request.node.get_closest_marker("skip_debug"):

python/tests/sync/test_basic.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ def test_basic(sandbox: Sandbox):
99

1010

1111
@pytest.mark.skip_debug
12-
def test_secure_access(sandbox_factory):
13-
sandbox = sandbox_factory(network={"allow_public_traffic": False})
12+
def test_secure_access(sandbox):
13+
sandbox = sandbox(network={"allow_public_traffic": False})
1414
# Create sandbox with public traffic disabled (secure access)
1515
result = sandbox.run_code("x =1; x")
1616
assert result.text == "1"

python/tests/sync/test_contexts.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ def test_restart_context(sandbox: Sandbox):
6666

6767
# Secure traffic tests (public traffic disabled)
6868
@pytest.mark.skip_debug
69-
def test_create_context_secure_traffic(sandbox_factory):
70-
sandbox = sandbox_factory(network={"allow_public_traffic": False})
69+
def test_create_context_secure_traffic(sandbox):
70+
sandbox = sandbox(network={"allow_public_traffic": False})
7171
context = sandbox.create_code_context()
7272

7373
contexts = sandbox.list_code_contexts()
@@ -79,8 +79,8 @@ def test_create_context_secure_traffic(sandbox_factory):
7979

8080

8181
@pytest.mark.skip_debug
82-
def test_remove_context_secure_traffic(sandbox_factory):
83-
sandbox = sandbox_factory(network={"allow_public_traffic": False})
82+
def test_remove_context_secure_traffic(sandbox):
83+
sandbox = sandbox(network={"allow_public_traffic": False})
8484
context = sandbox.create_code_context()
8585

8686
sandbox.remove_code_context(context.id)
@@ -90,8 +90,8 @@ def test_remove_context_secure_traffic(sandbox_factory):
9090

9191

9292
@pytest.mark.skip_debug
93-
def test_list_contexts_secure_traffic(sandbox_factory):
94-
sandbox = sandbox_factory(network={"allow_public_traffic": False})
93+
def test_list_contexts_secure_traffic(sandbox):
94+
sandbox = sandbox(network={"allow_public_traffic": False})
9595
contexts = sandbox.list_code_contexts()
9696

9797
# default contexts should include python and javascript
@@ -101,8 +101,8 @@ def test_list_contexts_secure_traffic(sandbox_factory):
101101

102102

103103
@pytest.mark.skip_debug
104-
def test_restart_context_secure_traffic(sandbox_factory):
105-
sandbox = sandbox_factory(network={"allow_public_traffic": False})
104+
def test_restart_context_secure_traffic(sandbox):
105+
sandbox = sandbox(network={"allow_public_traffic": False})
106106
context = sandbox.create_code_context()
107107

108108
# set a variable in the context

0 commit comments

Comments
 (0)