From: Elizabeth Uselton Date: Mon, 22 Jul 2019 01:45:50 +0000 (-0700) Subject: Revert "bpo-37555: Fix _CallList and _Call order sensitivity" X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=bdf430de3980c0733188e1b832176395f7bae234;p=thirdparty%2FPython%2Fcpython.git Revert "bpo-37555: Fix _CallList and _Call order sensitivity" This reverts commit 874fb697b8376fcea130116e56189061f944fde6. --- diff --git a/Lib/unittest/mock.py b/Lib/unittest/mock.py index c343cf4939ec..47592057e1b1 100644 --- a/Lib/unittest/mock.py +++ b/Lib/unittest/mock.py @@ -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__