fix(v0.40.3): width-independent help-text + fastapi-skip on CI

CI failures on this commit:
- macOS Typer help text wraps `--judge` / `--trace-log` to two lines on
  narrow CI terminals; tests asserted the raw string. Strip whitespace
  before match (mirrors v0.40.2 width-independent fix).
- `fastapi` is not in the base CI deps (only `[serve]` extra); two
  `_create_app` tests ImportError-ed. Skip those tests when fastapi is
  unavailable.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Alpamys 2026-05-08 16:13:04 +05:00
parent 1f050fc235
commit 18fc5b8d02
1 changed files with 27 additions and 4 deletions

View File

@ -3,6 +3,7 @@
from __future__ import annotations
import json
import re
from pathlib import Path
from types import SimpleNamespace
from unittest.mock import MagicMock
@ -234,8 +235,11 @@ class TestFromTracesJudgeCli:
runner = CliRunner()
result = runner.invoke(soup_app, ["data", "from-traces", "--help"])
assert result.exit_code == 0
assert "--judge" in result.output
assert "--min-confidence" in result.output
# Narrow terminals on CI may break a long flag across two lines
# (e.g. "--judge\n-provider"). Strip ANSI + whitespace before match.
cleaned = re.sub(r"\s+", "", result.output)
assert "--judge" in cleaned
assert "--min-confidence" in cleaned
def test_judge_provider_invalid_rejected_early(self, tmp_path, monkeypatch):
monkeypatch.chdir(tmp_path)
@ -512,19 +516,34 @@ class TestTraceLogWriter:
assert len(lines) == 20
_FASTAPI_AVAILABLE = True
try:
import fastapi # noqa: F401
except ImportError:
_FASTAPI_AVAILABLE = False
class TestServeTraceLogWiring:
def test_serve_help_lists_trace_log(self):
runner = CliRunner()
result = runner.invoke(soup_app, ["serve", "--help"])
assert result.exit_code == 0
assert "--trace-log" in result.output
# Narrow terminals on CI may break "--trace-log" across two lines
# (e.g. "--trace\n-log"). Strip whitespace before match.
cleaned = re.sub(r"\s+", "", result.output)
assert "--trace-log" in cleaned
def test_serve_help_lists_trace_log_cap_mb(self):
runner = CliRunner()
result = runner.invoke(soup_app, ["serve", "--help"])
assert result.exit_code == 0
assert "--trace-log-cap-mb" in result.output
cleaned = re.sub(r"\s+", "", result.output)
assert "--trace-log-cap-mb" in cleaned
@pytest.mark.skipif(
not _FASTAPI_AVAILABLE,
reason="fastapi not installed (only required for `serve` extras)",
)
def test_create_app_accepts_trace_log_writer(self, tmp_path, monkeypatch):
# Not building a real model — just assert the parameter is accepted
# and stored on app.state.
@ -545,6 +564,10 @@ class TestServeTraceLogWiring:
)
assert app.state.trace_log_writer is writer
@pytest.mark.skipif(
not _FASTAPI_AVAILABLE,
reason="fastapi not installed (only required for `serve` extras)",
)
def test_create_app_default_writer_is_none(self, tmp_path, monkeypatch):
from soup_cli.commands.serve import _create_app