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) # ---------------------------------------------------------------------------