MCPcopy Index your code
hub / github.com/python/cpython / assert_called_with

Method assert_called_with

Lib/unittest/mock.py:967–986  ·  view source on GitHub ↗

assert that the last call was made with the specified arguments. Raises an AssertionError if the args and keyword args passed in are different to the last call to the mock.

(self, /, *args, **kwargs)

Source from the content-addressed store, hash-verified

965 raise AssertionError(msg)
966
967 def assert_called_with(self, /, *args, **kwargs):
968 """assert that the last call was made with the specified arguments.
969
970 Raises an AssertionError if the args and keyword args passed in are
971 different to the last call to the mock."""
972 if self.call_args is None:
973 expected = self._format_mock_call_signature(args, kwargs)
974 actual = 'not called.'
975 error_message = ('expected call not found.\nExpected: %s\n Actual: %s'
976 % (expected, actual))
977 raise AssertionError(error_message)
978
979 def _error_message():
980 msg = self._format_mock_failure_message(args, kwargs)
981 return msg
982 expected = self._call_matcher(_Call((args, kwargs), two=True))
983 actual = self._call_matcher(self.call_args)
984 if actual != expected:
985 cause = expected if isinstance(expected, Exception) else None
986 raise AssertionError(_error_message()) from cause
987
988
989 def assert_called_once_with(self, /, *args, **kwargs):

Callers 15

assert_called_withFunction · 0.80
test_unregisterMethod · 0.80
test_open_argsMethod · 0.80
test_read_mime_typesMethod · 0.80
test_insertMethod · 0.80
test_move_leftMethod · 0.80
test_move_rightMethod · 0.80
test_move_upMethod · 0.80
test_move_downMethod · 0.80

Calls 3

_call_matcherMethod · 0.95
_CallClass · 0.85

Tested by 15

test_unregisterMethod · 0.64
test_open_argsMethod · 0.64
test_read_mime_typesMethod · 0.64
test_insertMethod · 0.64
test_move_leftMethod · 0.64
test_move_rightMethod · 0.64
test_move_upMethod · 0.64
test_move_downMethod · 0.64
_testMethod · 0.64