forked from OpenHands/OpenHands
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_command_success.py
More file actions
32 lines (27 loc) · 863 Bytes
/
test_command_success.py
File metadata and controls
32 lines (27 loc) · 863 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
from openhands.events.observation.commands import (
CmdOutputMetadata,
CmdOutputObservation,
IPythonRunCellObservation,
)
def test_cmd_output_success():
# Test successful command
obs = CmdOutputObservation(
command='ls',
content='file1.txt\nfile2.txt',
metadata=CmdOutputMetadata(exit_code=0),
)
assert obs.success is True
assert obs.error is False
# Test failed command
obs = CmdOutputObservation(
command='ls',
content='No such file or directory',
metadata=CmdOutputMetadata(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