Testing Command Execution and IPython Cell Operations in OpenHands
This test suite validates command execution outcomes and IPython cell operations in the OpenHands project, focusing on command output observation and IPython cell execution verification.
Test Coverage Overview
Implementation Analysis
Technical Details
Best Practices Demonstrated
all-hands-ai/openhands
tests/unit/test_command_success.py
from openhands.events.observation.commands import (
CmdOutputObservation,
IPythonRunCellObservation,
)
def test_cmd_output_success():
# Test successful command
obs = CmdOutputObservation(
command_id=1, command='ls', content='file1.txt
file2.txt', exit_code=0
)
assert obs.success is True
assert obs.error is False
# Test failed command
obs = CmdOutputObservation(
command_id=2, command='ls', content='No such file or directory', exit_code=1
)
assert obs.success is False
assert obs.error is True
def test_ipython_cell_success():
# IPython cells are always successful
obs = IPythonRunCellObservation(code='print("Hello")', content='Hello')
assert obs.success is True
assert obs.error is False