The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
test: capture worktree messages through the _cprint route
Teknium33e64fd83cfc
diff --git a/tests/hermes_cli/test_worktree_command.py b/tests/hermes_cli/test_worktree_command.pyindex af6563794fb..bf9443e7718 100644--- a/tests/hermes_cli/test_worktree_command.py+++ b/tests/hermes_cli/test_worktree_command.py@@ -28,8 +28,24 @@ class _Stub(CLICommandsMixin):def _run(stub, command):+ """Capture handler output.++ Worktree messages route through ``cli._cprint`` (the ANSI-aware+ prompt_toolkit renderer) since the garbled-escape fix; its output binds+ to the prompt_toolkit session output object, not ``sys.stdout``, so+ ``redirect_stdout`` alone cannot capture it. Mirror ``_cprint`` into the+ same buffer to keep asserting the user-visible text.+ """+ import re+ from unittest.mock import patch as _patch+buf = io.StringIO()- with contextlib.redirect_stdout(buf):+ ansi = re.compile(r"\x1b\[[0-9;]*m")++ def _fake_cprint(text):+ buf.write(ansi.sub("", str(text)) + "\n")++ with contextlib.redirect_stdout(buf), _patch.object(cli_mod, "_cprint", _fake_cprint):stub._handle_worktree_command(command)return buf.getvalue()