@@ -864,7 +864,7 @@ def assert_called_with(self, /, *args, **kwargs):
864864 def _error_message ():
865865 msg = self ._format_mock_failure_message (args , kwargs )
866866 return msg
867- expected = self ._call_matcher (_Call ((args , kwargs )))
867+ expected = self ._call_matcher (_Call ((args , kwargs ), two = True ))
868868 actual = self ._call_matcher (self .call_args )
869869 if actual != expected :
870870 cause = expected if isinstance (expected , Exception ) else None
@@ -927,9 +927,9 @@ def assert_any_call(self, /, *args, **kwargs):
927927 `assert_called_with` and `assert_called_once_with` that only pass if
928928 the call is the most recent one."""
929929 expected = self ._call_matcher (_Call ((args , kwargs ), two = True ))
930- cause = expected if isinstance (expected , Exception ) else None
931930 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
933933 expected_string = self ._format_mock_call_signature (args , kwargs )
934934 raise AssertionError (
935935 '%s call not found' % expected_string
@@ -982,23 +982,6 @@ def _calls_repr(self, prefix="Calls"):
982982 return f"\n { prefix } : { safe_repr (self .mock_calls )} ."
983983
984984
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-
1002985def _try_iter (obj ):
1003986 if obj is None :
1004987 return obj
@@ -2172,7 +2155,7 @@ def assert_any_await(self, /, *args, **kwargs):
21722155 """
21732156 expected = self ._call_matcher (_Call ((args , kwargs ), two = True ))
21742157 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 :
21762159 cause = expected if isinstance (expected , Exception ) else None
21772160 expected_string = self ._format_mock_call_signature (args , kwargs )
21782161 raise AssertionError (
0 commit comments