hermes-agent/tests/tools/test_terminal_timeout_output.py
alt-glitch 4b16341975 refactor(restructure): rewrite all imports for hermes_agent package
Rewrite all import statements, patch() targets, sys.modules keys,
importlib.import_module() strings, and subprocess -m references to use
hermes_agent.* paths.

Strip sys.path.insert hacks from production code (rely on editable install).
Update COMPONENT_PREFIXES for logger filtering.
Fix 3 hardcoded getLogger() calls to use __name__.
Update transport and tool registry discovery paths.
Update plugin module path strings.
Add legacy process-name patterns for gateway PID detection.
Add main() to skills_sync for console_script entry point.
Fix _get_bundled_dir() path traversal after move.

Part of #14182, #14183
2026-04-23 08:35:34 +05:30

27 lines
1.1 KiB
Python

"""Verify that terminal command timeouts preserve partial output."""
from hermes_agent.backends.local import LocalEnvironment
class TestTimeoutPreservesPartialOutput:
"""When a command times out, any output captured before the deadline
should be included in the result — not discarded."""
def test_timeout_includes_partial_output(self):
"""A command that prints then sleeps past the deadline should
return both the printed text and the timeout notice."""
env = LocalEnvironment()
result = env.execute("echo 'hello from test' && sleep 30", timeout=2)
assert result["returncode"] == 124
assert "hello from test" in result["output"]
assert "timed out" in result["output"].lower()
def test_timeout_with_no_output(self):
"""A command that produces nothing before timeout should still
return a clean timeout message."""
env = LocalEnvironment()
result = env.execute("sleep 30", timeout=1)
assert result["returncode"] == 124
assert "timed out" in result["output"].lower()
assert not result["output"].startswith("\n")