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

Function _patch_object

Lib/unittest/mock.py:1686–1712  ·  view source on GitHub ↗

patch the named member (`attribute`) on an object (`target`) with a mock object. `patch.object` can be used as a decorator, class decorator or a context manager. Arguments `new`, `spec`, `create`, `spec_set`, `autospec` and `new_callable` have the same meaning as for `patch`. L

(
        target, attribute, new=DEFAULT, spec=None,
        create=False, spec_set=None, autospec=None,
        new_callable=None, *, unsafe=False, **kwargs
    )

Source from the content-addressed store, hash-verified

1684
1685
1686def _patch_object(
1687 target, attribute, new=DEFAULT, spec=None,
1688 create=False, spec_set=None, autospec=None,
1689 new_callable=None, *, unsafe=False, **kwargs
1690 ):
1691 """
1692 patch the named member (`attribute`) on an object (`target`) with a mock
1693 object.
1694
1695 `patch.object` can be used as a decorator, class decorator or a context
1696 manager. Arguments `new`, `spec`, `create`, `spec_set`,
1697 `autospec` and `new_callable` have the same meaning as for `patch`. Like
1698 `patch`, `patch.object` takes arbitrary keyword arguments for configuring
1699 the mock object it creates.
1700
1701 When used as a class decorator `patch.object` honours `patch.TEST_PREFIX`
1702 for choosing which methods to wrap.
1703 """
1704 if type(target) is str:
1705 raise TypeError(
1706 f"{target!r} must be the actual object to be patched, not a str"
1707 )
1708 getter = lambda: target
1709 return _patch(
1710 getter, attribute, new, spec, create,
1711 spec_set, autospec, new_callable, kwargs, unsafe=unsafe
1712 )
1713
1714
1715def _patch_multiple(target, spec=None, create=False, spec_set=None,

Callers

nothing calls this directly

Calls 1

_patchClass · 0.70

Tested by

no test coverage detected