Skip to content

test(cli): normalise rich-panel output before asserting on BadParameter text - #7

Merged
ligon merged 1 commit into
mainfrom
fix/test-cli-rich-panel-wrap
Sep 9, 2026
Merged

test(cli): normalise rich-panel output before asserting on BadParameter text#7
ligon merged 1 commit into
mainfrom
fix/test-cli-rich-panel-wrap

Conversation

@ligon

@ligon ligon commented Sep 9, 2026

Copy link
Copy Markdown
Owner

main has been red on tests/test_cli.py::test_harness_and_legacy_agent_are_mutually_exclusive since f72f815 (the run on f863b38 was green) while the test passes locally. PR #6 inherits the same failure.

Cause. The message is raised as typer.BadParameter, which typer renders through a rich panel. typer/rich_utils.py sets force_terminal=True at import time whenever GITHUB_ACTIONS (or FORCE_COLOR / PY_COLORS) is set, so on Actions the panel is coloured and wrapped at the default 80 columns with no terminal attached, splitting the asserted substring across two bordered lines. Locally none of those variables is set and the assertion passes. Because the flag is a module-level constant, monkeypatch.delenv / NO_COLOR / CliRunner(env=...) cannot fix this from inside the test.

Reproduced with poetry.lock's typer 0.26.2 / rich 14.2.0: GITHUB_ACTIONS=true python -m pytest tests/test_cli.py -k mutually_exclusive alone flips the test from pass to fail.

Change. A _plain_output() helper that strips ANSI escapes and box-drawing characters and collapses whitespace; the assertion at tests/test_cli.py:417 runs against that. The sibling test at line 227 goes through typer.echo, not a panel, and is unaffected.

Verification. Full suite under GITHUB_ACTIONS=true with the lock-matched versions: 650 passed.

🤖 Generated with Claude Code

https://claude.ai/code/session_01StcQgXQDE4F6eJer1sEXRb

…er text

test_harness_and_legacy_agent_are_mutually_exclusive has failed on CI since
f72f815 while passing locally.  The message is raised as typer.BadParameter,
which typer renders through a rich panel; typer's rich_utils sets
force_terminal=True whenever GITHUB_ACTIONS (or FORCE_COLOR / PY_COLORS) is
set, so on Actions the panel is coloured and wrapped at the default 80
columns with no terminal attached, and the asserted substring is split
across two bordered lines.  Locally none of those variables is set, the
panel is not forced, and the assertion passes.

Reproduced with poetry.lock's typer 0.26.2 / rich 14.2.0:
GITHUB_ACTIONS=true alone flips the test from pass to fail.

Add a _plain_output() helper that strips ANSI escapes and box-drawing
characters and collapses whitespace, and assert against that.  The sibling
test at line 227 goes through typer.echo, not a panel, and is unaffected.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01StcQgXQDE4F6eJer1sEXRb
@ligon
ligon merged commit c2ab58e into main Sep 9, 2026
4 checks passed
@ligon
ligon deleted the fix/test-cli-rich-panel-wrap branch September 12, 2026 20:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant