diff --git a/tests/test_v0550.py b/tests/test_v0550.py index cdac113..b1df685 100644 --- a/tests/test_v0550.py +++ b/tests/test_v0550.py @@ -50,6 +50,17 @@ from soup_cli.utils.eval_lock_coverage import ( POSIX_ONLY = pytest.mark.skipif(os.name == "nt", reason="POSIX-only symlink test") +# Rich wraps option names with ANSI escapes when the terminal is narrow +# (macOS CI runners default to a smaller width than Linux/Windows), so +# substring searches like `"--goal" in output` fail without stripping. +# Project precedent: tests/test_auto_tuning.py, test_eval_platform.py, +# v0.53.5 / v0.53.6 / v0.53.8 / v0.53.9 CI hardening commits. +_ANSI_RE = re.compile(r"\x1b\[[0-9;]*m") + + +def _strip_ansi(text: str) -> str: + return _ANSI_RE.sub("", text) + # --------------------------------------------------------------------------- # Part A — Eval design from data @@ -760,7 +771,7 @@ class TestCLIPlumbing: from soup_cli.commands.eval import app result = self.runner.invoke(app, ["design", "--help"]) assert result.exit_code == 0, result.output - assert "--goal" in result.output + assert "--goal" in _strip_ansi(result.output) def test_eval_design_end_to_end(self, tmp_path, monkeypatch): from soup_cli.commands.eval import app @@ -901,9 +912,10 @@ class TestEvalAgainst: from soup_cli.commands.eval import app result = self.runner.invoke(app, ["against", "--help"]) assert result.exit_code == 0, (result.output, repr(result.exception)) - assert "--candidate" in result.output - assert "--metric" in result.output - assert "--json-only" in result.output + out = _strip_ansi(result.output) + assert "--candidate" in out + assert "--metric" in out + assert "--json-only" in out def test_against_requires_candidate(self): # `--candidate` is a required option; omitting must fail. diff --git a/tests/test_v0550_followups.py b/tests/test_v0550_followups.py index 0244681..9069605 100644 --- a/tests/test_v0550_followups.py +++ b/tests/test_v0550_followups.py @@ -502,15 +502,21 @@ class TestEvalAgainst: tracker.get_metric_series("run-1", "") def test_against_cli_help_lists_flag(self): + import re as _re + from typer.testing import CliRunner from soup_cli.commands.eval import app runner = CliRunner() result = runner.invoke(app, ["against", "--help"]) assert result.exit_code == 0, (result.output, repr(result.exception)) - assert "--candidate" in result.output - assert "--metric" in result.output - assert "--json-only" in result.output + # Strip Rich ANSI escapes — macOS CI uses a narrower terminal that + # wraps option names, breaking bare substring searches (precedent: + # v0.53.5/v0.53.6/v0.53.8/v0.53.9 CI hardening commits). + out = _re.sub(r"\x1b\[[0-9;]*m", "", result.output) + assert "--candidate" in out + assert "--metric" in out + assert "--json-only" in out # ---------------------------------------------------------------------------