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

Function _set_async_signature

Lib/unittest/mock.py:210–230  ·  view source on GitHub ↗
(mock, original, instance=False, is_async_mock=False)

Source from the content-addressed store, hash-verified

208 return funcopy
209
210def _set_async_signature(mock, original, instance=False, is_async_mock=False):
211 # creates an async function with signature (*args, **kwargs) that delegates to a
212 # mock. It still does signature checking by calling a lambda with the same
213 # signature as the original.
214
215 skipfirst = isinstance(original, type)
216 func, sig = _get_signature_object(original, instance, skipfirst)
217 def checksig(*args, **kwargs):
218 sig.bind(*args, **kwargs)
219 _copy_func_details(func, checksig)
220
221 name = original.__name__
222 context = {'_checksig_': checksig, 'mock': mock}
223 src = """async def %s(*args, **kwargs):
224 _checksig_(*args, **kwargs)
225 return await mock(*args, **kwargs)""" % name
226 exec (src, context)
227 funcopy = context[name]
228 _setup_func(funcopy, mock, sig)
229 _setup_async_mock(funcopy)
230 return funcopy
231
232
233def _setup_func(funcopy, mock, sig):

Callers 1

create_autospecFunction · 0.85

Calls 6

isinstanceFunction · 0.85
_get_signature_objectFunction · 0.85
_copy_func_detailsFunction · 0.85
_setup_funcFunction · 0.85
_setup_async_mockFunction · 0.85
execFunction · 0.50

Tested by

no test coverage detected