[Test Improver] fix(tests): strip ANSI codes before plain-text assertions in 3 test files#291
Draft
danielmeppiel wants to merge 1 commit intomainfrom
Draft
Conversation
…iles 7 tests were failing because Rich outputs bold/italic ANSI escape codes even when Click CliRunner captures output. Add _strip_ansi() helper (re.sub r'\x1b\[[0-9;]*m') to test_unpacker.py, test_update_command.py, and test_install_command.py, and apply it before assertions that check plain-text substrings in CLI output. 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
Goal
Fix 7 failing unit tests caused by Rich library injecting ANSI escape codes into CLI output captured by Click's
CliRunner.Root Cause
Rich outputs bold/italic ANSI codes (e.g.
\x1b[1m2\x1b[0m) even when output is captured byCliRunner. Tests that assert plain-text substrings like"Unpacked 2 file(s)"or"Successfully updated to version 0.7.0"fail because the actual output contains these codes between characters.Changes
Added a
_strip_ansi()helper to 3 test files and applied it before plain-text substring assertions:tests/unit/test_unpacker.pyTestUnpackCmdLoggingtests/unit/test_update_command.pyTestUpdateCommandtests/unit/test_install_command.pyTestInstallCommandAutoBootstrapThe helper is a one-liner:
Reproducibility