Fix mutants missed when tests clear os.environ - #552
Merged
Conversation
Keep a process-local copy of the active mutant so patch.dict(..., clear=True) cannot make the trampoline fall back to the original function.
Collaborator
|
Thank you, the change looks good to me! |
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.
Summary
Fixes #511.
patch.dict(os.environ, ..., clear=True)was wipingMUTANT_UNDER_TEST, so the trampoline forwarded every call to the original function and mutants only reached by those tests were reported as survived.As suggested in the issue, the active mutant is now also stored in process-local state. The trampoline still honors
MUTANT_UNDER_TESTwhen that key is present (existing tests and callers keep working). If the key is missing, it falls back to the process-local copy.Test plan
uv run pytest tests/— 379 passed, 4 skippedpatch.dict(os.environ, {"IN_DOCKER": "1"}, clear=True)