fix: 修复 CI 环境下 bumpversion -h 帮助输出 ANSI 转义码导致断言失败
CI / Lint, Typecheck & Test (push) Has been cancelled

This commit is contained in:
2026-07-08 21:52:34 +08:00
parent 18f4ee2957
commit 2d7bbd1a1f
+9 -1
View File
@@ -2,6 +2,7 @@
from __future__ import annotations
import re
import subprocess
from pathlib import Path
@@ -9,6 +10,13 @@ import pytest
from pyflowx.ops.dev import bumpversion
_ANSI_RE = re.compile(r"\x1b\[[0-9;]*[a-zA-Z]")
def _strip_ansi(text: str) -> str:
"""移除 ANSI 转义码,使断言在 CI(富终端) 与本地环境一致."""
return _ANSI_RE.sub("", text)
@pytest.fixture(autouse=True)
def auto_use_tmp_path(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> None:
@@ -205,7 +213,7 @@ class TestBumpversionCliDispatch:
app = PfApp(["bumpversion", "-h"])
rc = app.run()
assert rc == 0
out = capsys.readouterr().out
out = _strip_ansi(capsys.readouterr().out)
assert "--part" in out
assert "patch" in out