fix(tests): v0.60.0 CI green — widen version floors + strip ANSI from merge help assert

Three failures on CI run 26084542388 — all are version-pin / Rich-wrap
artefacts, not real regressions in v0.60.0 functionality:

- test_v0560 test_pyproject_version: regex-based >=0.56 floor check
  (was substring `version = "0.5`)
- test_v0590 test_version_is_0_59 -> test_version_is_at_least_0_59:
  >=0.59 floor (matches v0.51/v0.54 floor-check idiom)
- test_v0600_part_e merge_help_lists_license_flags: strip ANSI codes
  before substring check (Rich splits `--license` across `\x1b[1;36m`
  escapes in the wrapped Typer table)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Alpamys 2026-05-19 13:15:28 +05:00
parent f3c40e7753
commit 47409df730
3 changed files with 32 additions and 5 deletions

View File

@ -781,8 +781,16 @@ class TestSourceWiring:
assert __version__ >= "0.56.0"
def test_pyproject_version(self) -> None:
import re
text = (_PROJECT_ROOT / "pyproject.toml").read_text(encoding="utf-8")
assert 'version = "0.5' in text # floor check; current v0.5x.y
# Floor check — v0.56.0 was the first release that needed this guard.
# We accept any v0.<minor>.<patch> >= 0.56.0 so future releases (v0.6x,
# v0.7x, ...) don't have to edit this line.
m = re.search(r'^version = "(0\.\d+\.\d+)"', text, re.MULTILINE)
assert m, "pyproject.toml missing version line"
major, minor, _patch = m.group(1).split(".")
assert int(major) == 0 and int(minor) >= 56, m.group(1)
# --- review-fix coverage --------------------------------------------------

View File

@ -964,8 +964,14 @@ class TestSourceWiring:
assert "bom" in text.lower()
assert "attest" in text.lower()
def test_version_is_0_59(self):
assert soup_cli.__version__ == "0.59.0"
def test_version_is_at_least_0_59(self):
"""v0.59 floor — widens automatically as later releases bump version.
Matches the v0.51.0 / v0.54.0 floor-check idiom so later releases
don't have to edit this assertion.
"""
major, minor, _patch = soup_cli.__version__.split(".")
assert int(major) == 0 and int(minor) >= 59, soup_cli.__version__
def test_no_top_level_heavy_imports(self):
"""v0.59 modules must not import torch/transformers at module top."""

View File

@ -229,14 +229,27 @@ class TestMergeIntegration:
"""Regression: license gate is wired into `soup adapters merge`."""
def test_merge_help_lists_license_flags(self):
"""Both --license and --license-override must surface in the help text.
Rich's table renderer can split option names across ANSI styling
escape sequences, so a naive ``"--license" in result.output`` may
miss the bare option. We strip ANSI codes first.
"""
import re
from typer.testing import CliRunner
from soup_cli.cli import app
runner = CliRunner()
result = runner.invoke(app, ["adapters", "merge", "--help"])
assert result.exit_code == 0, (result.output, repr(result.exception))
assert "--license" in result.output
assert "--license-override" in result.output
# Strip ANSI escape sequences; merge whitespace.
clean = re.sub(r"\x1b\[[0-9;]*[mGKHF]", "", result.output)
clean = re.sub(r"\s+", " ", clean)
assert "--license-override" in clean
# Bare --license option (Typer may render with TEXT type hint
# immediately after); accept either form.
assert "--license " in clean or "--license\n" in clean or "--license " in result.output
def test_merge_refuses_license_conflict_without_override(self, tmp_path, monkeypatch):
"""Two adapters with incompatible licenses + no override → exit 3."""