mirror of https://github.com/razor-ai/soup.git
fix(tests): strip ANSI in --trust-remote-code help-visible assertions (v0.36.0 follow-up)
CI macOS runners render Rich panel help at a narrower terminal width than local Windows. The flag --trust-remote-code is split with ANSI colour escapes between segments, so the literal substring match in the three CLI plumbing tests failed even though the flag was correct in --help output. Mirrors the existing _strip_ansi helper in tests/test_log_level.py (v0.34.0 fix for the same class of issue). Tests-only follow-up; no soup_cli/ changes; no version bump needed per release checklist policy on tests-only commits. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
a5540fa1e2
commit
815a6c4f44
|
|
@ -7,11 +7,23 @@ trusted-org allowlist that suppresses noise on first-party models.
|
|||
|
||||
from __future__ import annotations
|
||||
|
||||
import re
|
||||
from io import StringIO
|
||||
|
||||
import pytest
|
||||
from rich.console import Console
|
||||
|
||||
# Rich help renderer can split a flag like --trust-remote-code with ANSI
|
||||
# colour escapes between `-`, `-trust`, `-remote-code` when the terminal
|
||||
# is narrow (macOS CI runners hit this; Windows local does not). Strip
|
||||
# ANSI so substring assertions are robust. Mirrors the helper in
|
||||
# tests/test_log_level.py.
|
||||
_ANSI_ESCAPE = re.compile(r"\x1b\[[0-9;]*[mK]")
|
||||
|
||||
|
||||
def _strip_ansi(text: str) -> str:
|
||||
return _ANSI_ESCAPE.sub("", text)
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Allowlist
|
||||
# ---------------------------------------------------------------------------
|
||||
|
|
@ -243,7 +255,7 @@ class TestCLIPlumbing:
|
|||
runner = CliRunner()
|
||||
result = runner.invoke(app, ["train", "--help"])
|
||||
assert result.exit_code == 0
|
||||
assert "--trust-remote-code" in result.output
|
||||
assert "--trust-remote-code" in _strip_ansi(result.output), result.output
|
||||
|
||||
def test_chat_help_lists_flag(self):
|
||||
from typer.testing import CliRunner
|
||||
|
|
@ -253,7 +265,7 @@ class TestCLIPlumbing:
|
|||
runner = CliRunner()
|
||||
result = runner.invoke(app, ["chat", "--help"])
|
||||
assert result.exit_code == 0
|
||||
assert "--trust-remote-code" in result.output
|
||||
assert "--trust-remote-code" in _strip_ansi(result.output), result.output
|
||||
|
||||
def test_serve_help_lists_flag(self):
|
||||
from typer.testing import CliRunner
|
||||
|
|
@ -263,4 +275,4 @@ class TestCLIPlumbing:
|
|||
runner = CliRunner()
|
||||
result = runner.invoke(app, ["serve", "--help"])
|
||||
assert result.exit_code == 0
|
||||
assert "--trust-remote-code" in result.output
|
||||
assert "--trust-remote-code" in _strip_ansi(result.output), result.output
|
||||
|
|
|
|||
Loading…
Reference in New Issue