Skip to content

Latest commit

 

History

History
82 lines (57 loc) · 2.67 KB

asynctest.mock.rst

File metadata and controls

82 lines (57 loc) · 2.67 KB

asynctest.mock

Mock classes

asynctest.Mock

asynctest.NonCallableMock

asynctest.MagicMock

asynctest.CoroutineMock

Patch

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 or asynctest.LIMITED, controls when the patch is activated on generators and coroutines

see

~asynctest.patch (details about scope) and unittest.mock.patch.dict.

Helpers

asynctest.mock_open

asynctest.return_once