From 4affc1a5c75768ee6040104876a2d1ec137abfcd Mon Sep 17 00:00:00 2001 From: Alpamys Date: Wed, 1 Apr 2026 18:16:09 +0500 Subject: [PATCH] fix: use ANSI-safe assertions in synth data pro help tests (macOS CI fix) --- tests/test_synth_data_pro.py | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/tests/test_synth_data_pro.py b/tests/test_synth_data_pro.py index 2a594df..9975ba9 100644 --- a/tests/test_synth_data_pro.py +++ b/tests/test_synth_data_pro.py @@ -6,11 +6,17 @@ quality pipeline (validate, filter, dedup), and security (SSRF). import json import os +import re from unittest.mock import MagicMock from unittest.mock import patch as mock_patch import pytest + +def _strip_ansi(text: str) -> str: + """Remove ANSI escape codes from Rich-formatted output.""" + return re.sub(r'\x1b\[[0-9;]*m', '', text) + # ─── Provider Validation Tests ────────────────────────────────────────── @@ -110,7 +116,8 @@ class TestNewProvidersCLIHelp: runner = CliRunner() result = runner.invoke(app, ["data", "generate", "--help"]) - assert "quality-pipeline" in result.output + clean = _strip_ansi(result.output) + assert "quality-pipeline" in clean # ─── Ollama Provider Tests ────────────────────────────────────────────── @@ -1049,10 +1056,11 @@ class TestQualityPipelineFlag: # We can test this by checking the help text mentions the flag runner = CliRunner() result = runner.invoke(app, ["data", "generate", "--help"]) - assert "quality-pipeline" in result.output - assert "validate" in result.output - assert "filter" in result.output - assert "dedup" in result.output + clean = _strip_ansi(result.output) + assert "quality-pipeline" in clean + assert "validate" in clean + assert "filter" in clean + assert "dedup" in clean # ─── Preference Validation Tests ──────────────────────────────────────── @@ -1182,7 +1190,8 @@ class TestOllamaModelShorthand: runner = CliRunner() result = runner.invoke(app, ["data", "generate", "--help"]) - assert "ollama-model" in result.output + clean = _strip_ansi(result.output) + assert "ollama-model" in clean # ─── Rate Limiting Tests ──────────────────────────────────────────────── @@ -1199,7 +1208,8 @@ class TestRateLimiting: runner = CliRunner() result = runner.invoke(app, ["data", "generate", "--help"]) - assert "requests-per-minute" in result.output or "rpm" in result.output + clean = _strip_ansi(result.output) + assert "requests-per-minute" in clean or "rpm" in clean # ─── Format Spec Tests ──────────────────────────────────────────────────