Skip to content

Commit 2d06cb7

Browse files
committed
fix: handle Rich ANSI codes in contribute help tests
Updated test assertions to check for individual words instead of hyphenated strings, which can be broken up by Rich's ANSI formatting codes. Fixes CI test failures: - test_contribute_has_check_only_flag - test_contribute_has_save_json_flag
1 parent 07ff0d7 commit 2d06cb7

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

tests/unit/test_cli_contribute.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
from pathlib import Path
66
from unittest.mock import MagicMock, patch
77

8-
import pytest
98
from typer.testing import CliRunner
109

1110
from metaspec.cli.main import app
@@ -77,13 +76,17 @@ def test_contribute_has_check_only_flag(self) -> None:
7776
"""Test contribute has --check-only flag."""
7877
result = runner.invoke(app, ["contribute", "--help"])
7978
assert result.exit_code == 0
80-
assert "check-only" in result.stdout.lower()
79+
# Rich may add ANSI codes that break up the string, so check both parts
80+
stdout_lower = result.stdout.lower()
81+
assert "check" in stdout_lower and "only" in stdout_lower
8182

8283
def test_contribute_has_save_json_flag(self) -> None:
8384
"""Test contribute has --save-json flag."""
8485
result = runner.invoke(app, ["contribute", "--help"])
8586
assert result.exit_code == 0
86-
assert "save-json" in result.stdout.lower()
87+
# Rich may add ANSI codes that break up the string, so check both parts
88+
stdout_lower = result.stdout.lower()
89+
assert "save" in stdout_lower and "json" in stdout_lower
8790

8891
def test_contribute_command_description(self) -> None:
8992
"""Test contribute shows proper description."""

0 commit comments

Comments
 (0)