mirror of https://github.com/razor-ai/soup.git
fix(v0.40.2): make help-text assertions width-independent
CI on Linux/macOS runners has narrower terminals than the local Windows shell. Rich wraps long option names like ``--template-dir`` across two lines (``-\n-template\x1b...-dir``) which makes a substring check on the raw output string fail. Updated `_plain` helper in both v0.40.2 test files to strip whitespace in addition to ANSI escapes — matches the option name regardless of terminal width. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
b0fc586706
commit
676078056d
|
|
@ -1,6 +1,7 @@
|
|||
"""Tests for v0.40.2 Part A — originally scheduled issues (#36, #50, #51)."""
|
||||
from __future__ import annotations
|
||||
|
||||
import re
|
||||
from io import StringIO
|
||||
|
||||
import pytest
|
||||
|
|
@ -12,6 +13,15 @@ from soup_cli.cli import app
|
|||
runner = CliRunner()
|
||||
|
||||
|
||||
def _plain(s: str) -> str:
|
||||
"""Strip ANSI escape sequences AND any whitespace inserted by Rich's
|
||||
width-aware option-name wrapping (e.g. ``-\\n-template-dir`` on narrow
|
||||
CI terminals).
|
||||
"""
|
||||
no_ansi = re.sub(r"\x1b\[[0-9;]*[a-zA-Z]", "", s)
|
||||
return re.sub(r"\s+", "", no_ansi)
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# #50 — `--hf-resume` prefer local newer
|
||||
# ---------------------------------------------------------------------------
|
||||
|
|
@ -249,7 +259,9 @@ class TestHfSpaceCustomTemplate:
|
|||
|
||||
def test_deploy_hf_space_help_shows_template_dir(self):
|
||||
result = runner.invoke(app, ["deploy", "hf-space", "--help"])
|
||||
assert "--template-dir" in result.output
|
||||
# Rich wraps long option names across lines on narrow CI terminals;
|
||||
# strip ANSI + whitespace to match the option name regardless.
|
||||
assert "--template-dir" in _plain(result.output)
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -13,8 +13,14 @@ runner = CliRunner()
|
|||
|
||||
|
||||
def _plain(s: str) -> str:
|
||||
"""Strip ANSI escape sequences for help-string assertions."""
|
||||
return re.sub(r"\x1b\[[0-9;]*[a-zA-Z]", "", s)
|
||||
"""Strip ANSI escape sequences AND whitespace.
|
||||
|
||||
Rich wraps long option names across lines on narrow CI terminals
|
||||
(``--template-\\n-dir``). Stripping whitespace makes the assertion
|
||||
width-independent.
|
||||
"""
|
||||
no_ansi = re.sub(r"\x1b\[[0-9;]*[a-zA-Z]", "", s)
|
||||
return re.sub(r"\s+", "", no_ansi)
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
|
|
|
|||
Loading…
Reference in New Issue