From 676078056de7c6b07fd4c624bd26ac59a9cb3888 Mon Sep 17 00:00:00 2001 From: Alpamys Date: Fri, 8 May 2026 13:26:44 +0500 Subject: [PATCH] fix(v0.40.2): make help-text assertions width-independent MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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) --- tests/test_v0402_part_a.py | 14 +++++++++++++- tests/test_v0402_part_b.py | 10 ++++++++-- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/tests/test_v0402_part_a.py b/tests/test_v0402_part_a.py index aa701a9..7432806 100644 --- a/tests/test_v0402_part_a.py +++ b/tests/test_v0402_part_a.py @@ -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) # --------------------------------------------------------------------------- diff --git a/tests/test_v0402_part_b.py b/tests/test_v0402_part_b.py index ed80b69..9a12d28 100644 --- a/tests/test_v0402_part_b.py +++ b/tests/test_v0402_part_b.py @@ -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) # ---------------------------------------------------------------------------