test(auto-tuning): strip ANSI from Typer --help output (v0.32.0 follow-up)

Rich/Typer emits per-character ANSI escapes in CI on Linux runners
("--\x1b[m-find\x1b[m-lr") so the raw substring assertion `--find-lr`
in result.output fails on ubuntu-latest x py3.12 even though it
passes on Windows where Rich auto-disables colour.

Strip ANSI before comparing — same pattern already used by
test_hf_integration.py and test_eval_platform.py.

Tests-only commit, no version bump.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Alpamys 2026-04-26 15:41:38 +05:00
parent 8878eb1aa6
commit 274490e6cc
1 changed files with 13 additions and 1 deletions

View File

@ -14,6 +14,7 @@ from __future__ import annotations
import json
import math
import re
from pathlib import Path
import pytest
@ -21,6 +22,17 @@ import yaml
from pydantic import ValidationError
from typer.testing import CliRunner
# Rich/Typer emits per-character ANSI escapes in CI ("--\x1b[m-find\x1b[m-lr"),
# so substring assertions on the raw `result.output` fail on Linux runners
# even though they pass on Windows where Rich auto-disables colour. Strip
# escapes before comparing — same pattern used by test_hf_integration.py
# and test_eval_platform.py.
_ANSI_RE = re.compile(r"\x1b\[[0-9;]*m")
def _strip_ansi(text: str) -> str:
return _ANSI_RE.sub("", text)
# --------------------------------------------------------------------------- #
# Part A — LR range finder #
# --------------------------------------------------------------------------- #
@ -164,7 +176,7 @@ class TestLRFinderCLI:
runner = CliRunner()
result = runner.invoke(app, ["train", "--help"])
assert result.exit_code == 0, (result.output, repr(result.exception))
assert "--find-lr" in result.output
assert "--find-lr" in _strip_ansi(result.output)
# --------------------------------------------------------------------------- #