[Test Improver] fix(tests): strip ANSI escape sequences in _ascii_only helper (test_policy_status.py)#977
Draft
danielmeppiel wants to merge 1 commit intomainfrom
Conversation
The test helper _ascii_only in test_policy_status.py was returning False for any control character (category Cc), which includes the ANSI ESC byte (U+001B) emitted by Rich for italic/bold styling even when NO_COLOR=1 is set (NO_COLOR suppresses colour codes but not all styling). Strip CSI escape sequences (\x1b[ ... <letter>) before the character loop, since the intent of _ascii_only is to detect non-ASCII Unicode content we author (emojis, smart-quotes) -- not to ban Rich's own ANSI rendering codes. This restores all 7 previously-failing assertions across TestStatusFoundOutcome, TestStatusNotFound, TestStatusDisabled, and TestStatusAsciiOnly. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.
🤖 Test Improver — automated AI assistant
Problem
tests/unit/commands/test_policy_status.py::TestStatusFoundOutcome::test_renders_found_outcomeand 6 sibling tests were failing with:Trade-offs
r"\x1b\[[0-9;]*[A-Za-z]"covers standard CSI sequences. Any non-CSI escape bytes still present after stripping (e.g. a stray bare\x1b) would be caught as a control character, preserving the safety net.