asynctest.mock
asynctest.Mock
asynctest.NonCallableMock
asynctest.MagicMock
asynctest.CoroutineMock
asynctest.GLOBAL
asynctest.LIMITED
asynctest.patch
asynctest.patch.object(target, attribute, new=DEFAULT, spec=None, create=False, spec_set=None, autospec=None, new_callable=None, scope=asynctest.GLOBAL, **kwargs)
Patch the named member (attribute
) on an object (target
) with a mock object, in the same fashion as ~asynctest.patch
.
See ~asynctest.patch
and unittest.mock.patch.object
.
asynctest.patch.multiple(target, spec=None, create=False, spec_set=None, autospec=None, new_callable=None, scope=asynctest.global, **kwargs)
Perform multiple patches in a single call. It takes the object to be patched (either as an object or a string to fetch the object by importing) and keyword arguments for the patches.
See ~asynctest.patch
and unittest.mock.patch.multiple
.
asynctest.patch.dict(in_dict, values=(), clear=False, scope=asynctest.GLOBAL, **kwargs)
Patch a dictionary, or dictionary like object, and restore the dictionary to its original state after the test.
Its behavior can be controlled on decorated generators and coroutines with scope
.
0.8 patch into generators and coroutines with a decorator.
- param in_dict
dictionary like object, or string referencing the object to patch.
- param values
a dictionary of values or an iterable of (key, value) pairs to set in the dictionary.
- param clear
if
True
, in_dict will be cleared before the new values are set.- param scope
asynctest.GLOBAL
orasynctest.LIMITED
, controls when the patch is activated on generators and coroutines- see
~asynctest.patch
(details aboutscope
) andunittest.mock.patch.dict
.
asynctest.mock_open
asynctest.return_once