Skip to content

Commit 8f0959a

Browse files
committed
Optimize test_delete_tmp_files by using single Docker executor
Reduce test runtime by ~10s by using one DockerCommandLineCodeExecutor instance instead of two. The delete_tmp_files=False case is covered implicitly by other tests using the module-scoped executor fixture.
1 parent 19f6633 commit 8f0959a

1 file changed

Lines changed: 4 additions & 11 deletions

File tree

python/packages/autogen-ext/tests/code_executors/test_docker_commandline_code_executor.py

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -334,19 +334,12 @@ async def test_delete_tmp_files() -> None:
334334
pytest.skip("Docker tests are disabled")
335335

336336
with tempfile.TemporaryDirectory() as temp_dir:
337-
# Test with delete_tmp_files=False (default)
338-
async with DockerCommandLineCodeExecutor(work_dir=temp_dir) as executor:
339-
cancellation_token = CancellationToken()
340-
code_blocks = [CodeBlock(code="print('test output')", language="python")]
341-
result = await executor.execute_code_blocks(code_blocks, cancellation_token)
342-
assert result.exit_code == 0
343-
assert result.code_file is not None
344-
# Verify file exists after execution
345-
assert Path(result.code_file).exists()
346-
347-
# Test with delete_tmp_files=True
337+
# Test with delete_tmp_files=True using a single executor instance
338+
# to avoid the overhead of creating multiple Docker containers.
348339
async with DockerCommandLineCodeExecutor(work_dir=temp_dir, delete_tmp_files=True) as executor:
349340
cancellation_token = CancellationToken()
341+
342+
# Test single code block
350343
code_blocks = [CodeBlock(code="print('test output')", language="python")]
351344
result = await executor.execute_code_blocks(code_blocks, cancellation_token)
352345
assert result.exit_code == 0

0 commit comments

Comments
 (0)