Fix properties dict mutation in testing.create_context#104
Conversation
AsyncTestCase.create_context used `properties = properties or {}`,
which keeps the caller's object, then wrote defaults into it via
setdefault(). A caller reusing the same non-empty dict across
create_context/process_message calls got stale content_type, type,
and timestamp on later calls, since setdefault sees the previously
written keys and refuses to overwrite them.
Copy the dict first (`dict(properties) if properties else {}`) so the
caller's object is never mutated and each call applies its own
defaults.
Closes #98
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthrough
ChangesProperties Dict Mutation Fix
Estimated code review effort: 1 (Trivial) | ~3 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
Comment |
|
@coderabbitai review |
✅ Action performedReview finished.
|
Summary
Fixes a bug where
testing.AsyncTestCase.create_contextmutated the caller-suppliedpropertiesdict.Problem / Solution
create_contextusedproperties = properties or {}(keeping the caller's object) then wrote defaults viasetdefault, so a caller reusing a non-empty dict acrossprocess_messagecalls got stalecontent_type/type/timestamp→ copy-on-entry (dict(properties) if properties else {}).Testing
Full suite green (209 tests) + ruff clean. New test in
tests/test_testing.pyreproduces the mutation (verified failing before, passing after).Closes #98
Summary by CodeRabbit