Skip to content

Read the CLI help with terminal escapes stripped - #3598

Merged
ESultanik merged 1 commit into
masterfrom
fix/cli-help-tests-ignore-color
Sep 18, 2026
Merged

ESultanik merged 1 commit into
masterfrom
fix/cli-help-tests-ignore-color

Conversation

@ESultanik

Copy link
Copy Markdown
Collaborator

Replaces #3596, which used British spellings in its branch name and prose. The fix is unchanged.

Python 3.14 colorizes argparse help, so --format and its choices are separated by a select-graphic-rendition escape:

'--format \x1b[33m{file,mime,html,json,sbud,explain}\x1b[0m]'

USAGE_CHOICES never matches that, so test_no_duplicate_choices and test_help_example_uses_real_arguments both fail on any developer machine running 3.14. They pass in CI only because stdout there is not a terminal, which means the 3.14 matrix job is not exercising what it looks like it is exercising.

cli_help now strips the escapes. Turning the color off through an environment variable would work today, but which variable and which interpreter honor it is outside this project's control, so the tests read what a reader sees instead.

Verified passing with PYTHON_COLORS=1 FORCE_COLOR=1, with PYTHON_COLORS=0 NO_COLOR=1, and with neither set; and verified still failing when a duplicate --format choice is reintroduced, so the assertion it guards still bites.

Merge order: independent of every other open pull request.

🤖 Generated with Claude Code

Python 3.14 colorizes argparse help, so `--format` and its choices are
separated by a select-graphic-rendition escape and `USAGE_CHOICES` never
matches. `test_no_duplicate_choices` and
`test_help_example_uses_real_arguments` both fail on any developer
machine running 3.14, and both pass in CI only because stdout there is
not a terminal.

`cli_help` now strips the escapes. Turning the color off through an
environment variable would work today, but which variable and which
interpreter honor it is outside this project's control, so the tests read
what a reader sees instead.

Verified passing with PYTHON_COLORS and FORCE_COLOR set, with
PYTHON_COLORS and NO_COLOR clear, and with neither, and verified still
failing when a duplicate `--format` choice is reintroduced.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@ESultanik ESultanik self-assigned this Sep 18, 2026
@ESultanik
ESultanik merged commit d65e474 into master Sep 18, 2026
14 checks passed
@ESultanik
ESultanik deleted the fix/cli-help-tests-ignore-color branch September 18, 2026 20:01
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