Skip to content

Commit af78391

Browse files
committed
Fix test
1 parent 9e84e94 commit af78391

1 file changed

Lines changed: 11 additions & 3 deletions

File tree

tests/test_cli_helpers.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from __future__ import annotations
44

55
import json
6+
import re
67
from io import StringIO
78
from pathlib import Path
89

@@ -18,6 +19,12 @@
1819
)
1920
from cocoindex_code.protocol import SearchResponse, SearchResult
2021

22+
_ANSI_RE = re.compile(r"\x1b\[[0-?]*[ -/]*[@-~]")
23+
24+
25+
def _strip_ansi(text: str) -> str:
26+
return _ANSI_RE.sub("", text)
27+
2128

2229
def test_require_project_root_success(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> None:
2330
project = tmp_path / "project"
@@ -94,8 +101,9 @@ def test_search_help_includes_json_option() -> None:
94101
result = runner.invoke(cli.app, ["search", "--help"], catch_exceptions=False)
95102

96103
assert result.exit_code == 0
97-
assert "--json" in result.output
98-
assert "--repo-key" in result.output
104+
output = _strip_ansi(result.output)
105+
assert "--json" in output
106+
assert "--repo-key" in output
99107

100108

101109
def test_bridge_help_includes_jsonrpc_option() -> None:
@@ -104,7 +112,7 @@ def test_bridge_help_includes_jsonrpc_option() -> None:
104112
result = runner.invoke(cli.app, ["bridge", "--help"], catch_exceptions=False)
105113

106114
assert result.exit_code == 0
107-
assert "--jsonrpc" in result.output
115+
assert "--jsonrpc" in _strip_ansi(result.output)
108116

109117

110118
def test_print_search_results_json_outputs_machine_readable_payload(

0 commit comments

Comments
 (0)