]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Revert "bpo-37555: Fix _CallList and _Call order sensitivity"
authorElizabeth Uselton <elizabeth.uselton@rover.com>
Mon, 22 Jul 2019 01:45:50 +0000 (18:45 -0700)
committerElizabeth Uselton <elizabeth.uselton@rover.com>
Mon, 22 Jul 2019 01:45:50 +0000 (18:45 -0700)
This reverts commit 874fb697b8376fcea130116e56189061f944fde6.

Lib/unittest/mock.py

index c343cf4939ecb429765a428475997d61d01c0779..47592057e1b1c03e4dc1b5b1743350f74c9fb8c1 100644 (file)
@@ -337,19 +337,13 @@ class _CallList(list):
 
         for i in range(0, len_self - len_value + 1):
             sub_list = self[i:i+len_value]
-            if value == sub_list:
+            if sub_list == value:
                 return True
         return False
 
     def __repr__(self):
         return pprint.pformat(list(self))
 
-    def __eq__(self, other):
-        self_list = list(self)
-        other_list = list(other)
-        # checking equality both directions is necessary for ANY to work
-        return self_list.__eq__(other_list) or other_list.__eq__(self_list)
-
 
 def _check_and_set_parent(parent, value, name, new_name):
     # function passed to create_autospec will have mock
@@ -2300,6 +2294,7 @@ def _format_call_signature(name, args, kwargs):
     return message % formatted_args
 
 
+
 class _Call(tuple):
     """
     A tuple for holding the results of a call to a mock, either in the form
@@ -2409,12 +2404,8 @@ class _Call(tuple):
         if self_name and other_name != self_name:
             return False
 
-        self_params = self_args, self_kwargs
-        other_params = other_args, other_kwargs
-        return (
-            self_params.__eq__(other_params)
-            or other_params.__eq__(self_params)
-        )
+        # this order is important for ANY to work!
+        return (other_args, other_kwargs) == (self_args, self_kwargs)
 
 
     __ne__ = object.__ne__