Repository navigation
Don't produce equivalent case mutants inside string escape sequences - #611
Merged
Merged
Conversation
Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Owner
|
Thanks! |
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.
String mutations that case-flip characters were also changing the hex digits inside escape sequences like
\u00a0,\xHH,\UHHHHHHHH, and the names inside\N{NAME}. Python treats those hex digits and unicode names case-insensitively, so mutants like"\u00A0"are equivalent to the original"\u00a0"and can never be killed by tests.What changed
Modified the
NON_ESCAPE_SEQUENCEregex insrc/mutmut/mutation/mutators.pyto match and preserve complete escape sequences with case-insensitive hex digits or names (\xHH,\uHHHH,\UHHHHHHHH,\N{NAME}), while still allowing case transformations for regular text and for raw strings (where escape sequences are literal and case changes are not equivalent).Updated the existing test expectation for
\N{ghost} \U11223344to reflect that these are now preserved, and adjusted the e2e snapshot (4 mutants instead of 5, dropping the equivalent one).How it was tested
\u,\U,\x,\N{...}escapes and mixed contentr"..."), where case changes are not equivalent and still happenAn AI coding assistant helped with the implementation.
Fixes #609