-
-
Notifications
You must be signed in to change notification settings - Fork 32.5k
bpo-37555: Update _CallList.__contains__ to respect ANY #14700
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
94ddf54
Flip equality to use mock calls' __eq__
ElizabethU b4c7d78
bpo-37555: Regression test demonstrating assert_has_calls not working…
ElizabethU ad99a9d
Revert "Flip equality to use mock calls' __eq__"
ElizabethU 49c5310
bpo-37555: Add regression tests for mock ANY ordering issues
ElizabethU 874fb69
bpo-37555: Fix _CallList and _Call order sensitivity
ElizabethU d72d6f5
bpo-37555: Ensure _call_matcher returns _Call object
ElizabethU f0e8411
Adding ACK and news entry
ElizabethU f295eac
bpo-37555: Replacing __eq__ with == to sidestep NotImplemented
ElizabethU 18e964b
bpo-37555: cleaning up changes unnecessary to the final product
ElizabethU 883841a
bpo-37555: Fixed call on bound arguments to respect args and kwargs
ElizabethU f4844c7
Revert "bpo-37555: Add regression tests for mock ANY ordering issues"
ElizabethU 84489c8
Revert "bpo-37555: cleaning up changes unnecessary to the final product"
ElizabethU 344ef17
Revert "bpo-37555: Replacing __eq__ with == to sidestep NotImplemented"
ElizabethU bdf430d
Revert "bpo-37555: Fix _CallList and _Call order sensitivity"
ElizabethU d3522b1
Updated NEWS.d
ElizabethU f47699d
bpo-37555: Add tests checking every function using _call_matcher both…
ElizabethU 38650c9
bpo-37555: Ensure all assert methods using _call_matcher are actually…
ElizabethU 24973c0
Remove AnyCompare and use call objects everywhere.
tirkarthi 001d708
Revert "Remove AnyCompare and use call objects everywhere."
ElizabethU 25dec66
Check for exception in assert_any_await
ElizabethU File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
bpo-37555: Fix _CallList and _Call order sensitivity
_Call and _CallList depend on ordering to correctly process that an object being compared to ANY with __eq__ should return True. This fix updates the comparison to check both a == b and b == a and return True if either condition is met, fixing situations from the tests in the previous two commits where assertEqual would not be commutative if checking _Call or _CallList objects. This seems like a reasonable fix considering that the Python data model specifies that if an object doesn't know how to compare itself to another object it should return NotImplemented, and that on getting NotImplemented from a == b, it should try b == a, implying that good behavior for __eq__ is commutative. This also flips the order of comparison in _CallList's __contains__ method, guaranteeing ANY will be on the left and have it's __eq__ called for equality checking, fixing the interaction between assert_has_calls and ANY. Co-author: Neal Finne <neal@neal.finne.com>
- Loading branch information
commit 874fb697b8376fcea130116e56189061f944fde6
There are no files selected for viewing
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
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.
Uh oh!
There was an error while loading. Please reload this page.