From 815a6c4f44f5ac7e4c1630e3440a1df500439df7 Mon Sep 17 00:00:00 2001 From: Alpamys Date: Thu, 30 Apr 2026 12:01:01 +0500 Subject: [PATCH] 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) --- tests/test_trust_remote_code.py | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/tests/test_trust_remote_code.py b/tests/test_trust_remote_code.py index 92295f3..884a115 100644 --- a/tests/test_trust_remote_code.py +++ b/tests/test_trust_remote_code.py @@ -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