MCPcopy Index your code
hub / github.com/RustPython/RustPython / _call_matcher

Method _call_matcher

Lib/unittest/mock.py:911–936  ·  view source on GitHub ↗

Given a call (or simply an (args, kwargs) tuple), return a comparison key suitable for matching with other calls. This is a best effort method which relies on the spec's signature, if available, or falls back on the arguments themselves.

(self, _call)

Source from the content-addressed store, hash-verified

909
910
911 def _call_matcher(self, _call):
912 """
913 Given a call (or simply an (args, kwargs) tuple), return a
914 comparison key suitable for matching with other calls.
915 This is a best effort method which relies on the spec's signature,
916 if available, or falls back on the arguments themselves.
917 """
918
919 if isinstance(_call, tuple) and len(_call) > 2:
920 sig = self._get_call_signature_from_name(_call[0])
921 else:
922 sig = self._spec_signature
923
924 if sig is not None:
925 if len(_call) == 2:
926 name = ''
927 args, kwargs = _call
928 else:
929 name, args, kwargs = _call
930 try:
931 bound_call = sig.bind(*args, **kwargs)
932 return call(name, bound_call.args, bound_call.kwargs)
933 except TypeError as e:
934 return e.with_traceback(None)
935 else:
936 return _call
937
938 def assert_not_called(self):
939 """assert that the mock was never called.

Callers 6

assert_called_withMethod · 0.95
assert_has_callsMethod · 0.95
assert_any_callMethod · 0.95
assert_awaited_withMethod · 0.80
assert_any_awaitMethod · 0.80
assert_has_awaitsMethod · 0.80

Calls 6

isinstanceFunction · 0.85
lenFunction · 0.85
with_tracebackMethod · 0.80
callFunction · 0.50
bindMethod · 0.45

Tested by

no test coverage detected