mirror of https://github.com/razor-ai/soup.git
fix(tests): strip ANSI escapes before --lang substring assertion
Rich on narrow Windows columns splits `--lang` across colour-cycle ANSI escapes (`\x1b[..m-\x1b[..m-lang`), so the literal substring check fails on CI even though the rendered help renders correctly for humans. CI was red on every commit landing after #234 hit a runner with that exact column width + Python 3.9 + Rich combination. Mirrors the `_ANSI_RE` strip pattern in tests/test_auto_tuning.py — flat regex over the captured output before the `in` check.
This commit is contained in:
parent
148cb0c125
commit
6ec9db3ca7
|
|
@ -11,6 +11,7 @@ from __future__ import annotations
|
|||
|
||||
import dataclasses
|
||||
import json
|
||||
import re
|
||||
from pathlib import Path
|
||||
from types import MappingProxyType
|
||||
|
||||
|
|
@ -20,6 +21,12 @@ from typer.testing import CliRunner
|
|||
from soup_cli.cli import app
|
||||
from soup_cli.utils import brain_rot, brain_rot_lang
|
||||
|
||||
# Strip Rich's ANSI escape sequences before substring assertions — on narrow
|
||||
# Windows columns Rich can split a flag across colour-cycle escapes
|
||||
# (e.g. `\x1b[..m-\x1b[..m-lang`), so the literal `--lang` substring fails on
|
||||
# CI even though the rendered help looks correct. Mirrors tests/test_auto_tuning.py.
|
||||
_ANSI_RE = re.compile(r"\x1b\[[0-9;]*m")
|
||||
|
||||
|
||||
def _write(path: Path, text: str) -> Path:
|
||||
path.write_text(text, encoding="utf-8")
|
||||
|
|
@ -451,7 +458,7 @@ class TestBrainRotCliLang:
|
|||
runner = CliRunner()
|
||||
result = runner.invoke(app, ["data", "brain-rot", "--help"])
|
||||
assert result.exit_code == 0, result.output
|
||||
assert "--lang" in result.output
|
||||
assert "--lang" in _ANSI_RE.sub("", result.output)
|
||||
|
||||
def test_lang_en_default(
|
||||
self, tmp_path: Path, monkeypatch: pytest.MonkeyPatch
|
||||
|
|
|
|||
Loading…
Reference in New Issue