mirror of
https://github.com/headroomlabs-ai/headroom.git
synced 2026-11-22 13:29:19 +08:00
test(cli): assert the missing-binary error goes to stderr, not stdout
The existing missing-binary tests read merged output, so they could not catch the message moving back to stdout. The new test checks stdout is empty, stderr starts with the error, exit code is 1 and no proxy start is attempted, for a hand-written command (aider), a registry command (goose) and a two-name one (kimi). It fails on origin/main, where the message went to stdout. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Assisted-by: claude-code:claude-opus-5-5 Headline-Session: 6e77a807-8dd4-4a77-a2fa-ddce6dc2515e Headline-AI-Share: 89% strict / 89% weighted
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
872660959a
commit
ed29a8ce21
@@ -1145,3 +1145,33 @@ def test_no_proxy_does_not_create_startup_lock(monkeypatch: pytest.MonkeyPatch)
|
||||
|
||||
assert wrap_mod._ensure_proxy(8787, True) == (None, 8787)
|
||||
assert entered is False
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
("argv", "expected"),
|
||||
[
|
||||
(
|
||||
["wrap", "aider"],
|
||||
"Error: 'aider' not found in PATH.\nInstall aider: pip install aider-chat",
|
||||
),
|
||||
(["wrap", "goose"], "Error: 'goose' not found in PATH."),
|
||||
(["wrap", "kimi"], "Error: 'kimi' (or 'kimi-cli') not found in PATH."),
|
||||
],
|
||||
)
|
||||
def test_missing_binary_error_goes_to_stderr_only(
|
||||
monkeypatch: pytest.MonkeyPatch, tmp_path: Path, argv: list[str], expected: str
|
||||
) -> None:
|
||||
"""The missing-binary error is a ClickException on stderr; stdout stays empty."""
|
||||
monkeypatch.chdir(tmp_path)
|
||||
monkeypatch.setattr(wrap_mod.shutil, "which", lambda name: None)
|
||||
|
||||
def no_proxy(*args: Any, **kwargs: Any) -> None:
|
||||
raise AssertionError("a missing binary must fail before any proxy start")
|
||||
|
||||
monkeypatch.setattr(wrap_mod, "_ensure_proxy", no_proxy)
|
||||
|
||||
result = CliRunner().invoke(main, argv)
|
||||
|
||||
assert result.exit_code == 1
|
||||
assert result.stdout == ""
|
||||
assert result.stderr.startswith(expected)
|
||||
|
||||
Reference in New Issue
Block a user