@@ -864,7 +864,7 @@ def assert_called_with(self, /, *args, **kwargs):
864
864
def _error_message ():
865
865
msg = self ._format_mock_failure_message (args , kwargs )
866
866
return msg
867
- expected = self ._call_matcher (_Call ((args , kwargs )))
867
+ expected = self ._call_matcher (_Call ((args , kwargs ), two = True ))
868
868
actual = self ._call_matcher (self .call_args )
869
869
if actual != expected :
870
870
cause = expected if isinstance (expected , Exception ) else None
@@ -927,9 +927,9 @@ def assert_any_call(self, /, *args, **kwargs):
927
927
`assert_called_with` and `assert_called_once_with` that only pass if
928
928
the call is the most recent one."""
929
929
expected = self ._call_matcher (_Call ((args , kwargs ), two = True ))
930
- cause = expected if isinstance (expected , Exception ) else None
931
930
actual = [self ._call_matcher (c ) for c in self .call_args_list ]
932
- if cause or expected not in _AnyComparer (actual ):
931
+ if expected not in actual :
932
+ cause = expected if isinstance (expected , Exception ) else None
933
933
expected_string = self ._format_mock_call_signature (args , kwargs )
934
934
raise AssertionError (
935
935
'%s call not found' % expected_string
@@ -982,23 +982,6 @@ def _calls_repr(self, prefix="Calls"):
982
982
return f"\n { prefix } : { safe_repr (self .mock_calls )} ."
983
983
984
984
985
- class _AnyComparer (list ):
986
- """A list which checks if it contains a call which may have an
987
- argument of ANY, flipping the components of item and self from
988
- their traditional locations so that ANY is guaranteed to be on
989
- the left."""
990
- def __contains__ (self , item ):
991
- for _call in self :
992
- if len (item ) != len (_call ):
993
- continue
994
- if all ([
995
- expected == actual
996
- for expected , actual in zip (item , _call )
997
- ]):
998
- return True
999
- return False
1000
-
1001
-
1002
985
def _try_iter (obj ):
1003
986
if obj is None :
1004
987
return obj
@@ -2172,7 +2155,7 @@ def assert_any_await(self, /, *args, **kwargs):
2172
2155
"""
2173
2156
expected = self ._call_matcher (_Call ((args , kwargs ), two = True ))
2174
2157
actual = [self ._call_matcher (c ) for c in self .await_args_list ]
2175
- if expected not in _AnyComparer ( actual ) :
2158
+ if expected not in actual :
2176
2159
cause = expected if isinstance (expected , Exception ) else None
2177
2160
expected_string = self ._format_mock_call_signature (args , kwargs )
2178
2161
raise AssertionError (
0 commit comments