@@ -869,7 +869,7 @@ def assert_called_with(self, /, *args, **kwargs):
869869 def _error_message ():
870870 msg = self ._format_mock_failure_message (args , kwargs )
871871 return msg
872- expected = self ._call_matcher (_Call ((args , kwargs )))
872+ expected = self ._call_matcher (_Call ((args , kwargs ), two = True ))
873873 actual = self ._call_matcher (self .call_args )
874874 if actual != expected :
875875 cause = expected if isinstance (expected , Exception ) else None
@@ -932,9 +932,9 @@ def assert_any_call(self, /, *args, **kwargs):
932932 `assert_called_with` and `assert_called_once_with` that only pass if
933933 the call is the most recent one."""
934934 expected = self ._call_matcher (_Call ((args , kwargs ), two = True ))
935- cause = expected if isinstance (expected , Exception ) else None
936935 actual = [self ._call_matcher (c ) for c in self .call_args_list ]
937- if cause or expected not in _AnyComparer (actual ):
936+ if expected not in actual :
937+ cause = expected if isinstance (expected , Exception ) else None
938938 expected_string = self ._format_mock_call_signature (args , kwargs )
939939 raise AssertionError (
940940 '%s call not found' % expected_string
@@ -987,23 +987,6 @@ def _calls_repr(self, prefix="Calls"):
987987 return f"\n { prefix } : { safe_repr (self .mock_calls )} ."
988988
989989
990- class _AnyComparer (list ):
991- """A list which checks if it contains a call which may have an
992- argument of ANY, flipping the components of item and self from
993- their traditional locations so that ANY is guaranteed to be on
994- the left."""
995- def __contains__ (self , item ):
996- for _call in self :
997- if len (item ) != len (_call ):
998- continue
999- if all ([
1000- expected == actual
1001- for expected , actual in zip (item , _call )
1002- ]):
1003- return True
1004- return False
1005-
1006-
1007990def _try_iter (obj ):
1008991 if obj is None :
1009992 return obj
@@ -2177,7 +2160,7 @@ def assert_any_await(self, /, *args, **kwargs):
21772160 """
21782161 expected = self ._call_matcher (_Call ((args , kwargs ), two = True ))
21792162 actual = [self ._call_matcher (c ) for c in self .await_args_list ]
2180- if expected not in _AnyComparer ( actual ) :
2163+ if expected not in actual :
21812164 cause = expected if isinstance (expected , Exception ) else None
21822165 expected_string = self ._format_mock_call_signature (args , kwargs )
21832166 raise AssertionError (
0 commit comments