test(cli): normalise rich-panel output before asserting on BadParameter text - #7
Merged
Merged
Conversation
…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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
mainhas been red ontests/test_cli.py::test_harness_and_legacy_agent_are_mutually_exclusivesince 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.pysetsforce_terminal=Trueat import time wheneverGITHUB_ACTIONS(orFORCE_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_exclusivealone 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 attests/test_cli.py:417runs against that. The sibling test at line 227 goes throughtyper.echo, not a panel, and is unaffected.Verification. Full suite under
GITHUB_ACTIONS=truewith the lock-matched versions: 650 passed.🤖 Generated with Claude Code
https://claude.ai/code/session_01StcQgXQDE4F6eJer1sEXRb