summaryrefslogtreecommitdiffstats
path: root/Misc
diff options
context:
space:
mode:
authorElizabeth Uselton <elizabeth.uselton@gmail.com>2019-09-13 15:54:32 (GMT)
committerPaul Ganssle <paul@ganssle.io>2019-09-13 15:54:32 (GMT)
commitd6a9d17d8b6c68073931dd8ffa213b4ac351a4ab (patch)
treec82aa760a1be67480665af5132171728603838c9 /Misc
parent81319a81b2a3f42fe1047c2e6f5fd958faab6cdb (diff)
downloadcpython-d6a9d17d8b6c68073931dd8ffa213b4ac351a4ab.zip
cpython-d6a9d17d8b6c68073931dd8ffa213b4ac351a4ab.tar.gz
cpython-d6a9d17d8b6c68073931dd8ffa213b4ac351a4ab.tar.bz2
bpo-37555: Update _CallList.__contains__ to respect ANY (#14700)
* Flip equality to use mock calls' __eq__ * bpo-37555: Regression test demonstrating assert_has_calls not working with ANY and spec_set Co-authored-by: Neal Finne <neal@nealfinne.com> * Revert "Flip equality to use mock calls' __eq__" This reverts commit 94ddf54c5a8aab7d00d9ab93e1cc5695c28d73e7. * bpo-37555: Add regression tests for mock ANY ordering issues Add regression tests for whether __eq__ is order agnostic on _Call and _CallList, which is useful for comparisons involving ANY, especially if the ANY comparison is to a class not defaulting __eq__ to NotImplemented. Co-authored-by: Neal Finne <neal@nealfinne.com> * 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> * bpo-37555: Ensure _call_matcher returns _Call object * Adding ACK and news entry * bpo-37555: Replacing __eq__ with == to sidestep NotImplemented bool(NotImplemented) returns True, so it's necessary to use == instead of __eq__ in this comparison. * bpo-37555: cleaning up changes unnecessary to the final product * bpo-37555: Fixed call on bound arguments to respect args and kwargs * Revert "bpo-37555: Add regression tests for mock ANY ordering issues" This reverts commit 49c5310ad493c4356dd3bc58c03653cd9466c4fa. * Revert "bpo-37555: cleaning up changes unnecessary to the final product" This reverts commit 18e964ba0126d8964d89842cb95534b63c2d326e. * Revert "bpo-37555: Replacing __eq__ with == to sidestep NotImplemented" This reverts commit f295eaca5bceac6636c0e2b10e6c7d9a8ee8296a. * Revert "bpo-37555: Fix _CallList and _Call order sensitivity" This reverts commit 874fb697b8376fcea130116e56189061f944fde6. * Updated NEWS.d * bpo-37555: Add tests checking every function using _call_matcher both with and without spec * bpo-37555: Ensure all assert methods using _call_matcher are actually passing calls * Remove AnyCompare and use call objects everywhere. * Revert "Remove AnyCompare and use call objects everywhere." This reverts commit 24973c0b32ce7d796a7f4eeaf259832222aae0f5. * Check for exception in assert_any_await
Diffstat (limited to 'Misc')
-rw-r--r--Misc/ACKS2
-rw-r--r--Misc/NEWS.d/next/Library/2019-07-19-20-13-48.bpo-37555.S5am28.rst2
2 files changed, 4 insertions, 0 deletions
diff --git a/Misc/ACKS b/Misc/ACKS
index f321131..71e61c3 100644
--- a/Misc/ACKS
+++ b/Misc/ACKS
@@ -503,6 +503,7 @@ Tomer Filiba
Segev Finer
Jeffrey Finkelstein
Russell Finn
+Neal Finne
Dan Finnie
Nils Fischbeck
Frederik Fix
@@ -1714,6 +1715,7 @@ Roger Upole
Daniel Urban
Michael Urman
Hector Urtubia
+Elizabeth Uselton
Lukas Vacek
Ville Vainio
Yann Vaginay
diff --git a/Misc/NEWS.d/next/Library/2019-07-19-20-13-48.bpo-37555.S5am28.rst b/Misc/NEWS.d/next/Library/2019-07-19-20-13-48.bpo-37555.S5am28.rst
new file mode 100644
index 0000000..16d1d62
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2019-07-19-20-13-48.bpo-37555.S5am28.rst
@@ -0,0 +1,2 @@
+Fix `NonCallableMock._call_matcher` returning tuple instead of `_Call` object
+when `self._spec_signature` exists. Patch by Elizabeth Uselton \ No newline at end of file