From 274490e6cc5d3bc94ed63b03d7b08348785300e6 Mon Sep 17 00:00:00 2001 From: Alpamys Date: Sun, 26 Apr 2026 15:41:38 +0500 Subject: [PATCH] test(auto-tuning): strip ANSI from Typer --help output (v0.32.0 follow-up) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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) --- tests/test_auto_tuning.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/tests/test_auto_tuning.py b/tests/test_auto_tuning.py index b10401b..2712527 100644 --- a/tests/test_auto_tuning.py +++ b/tests/test_auto_tuning.py @@ -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) # --------------------------------------------------------------------------- #