Skip to content

Commit 892b72f

Browse files
committed
Pytest: Adds patching.object (works like mock.patch.object)
1 parent f1143b8 commit 892b72f

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

case/pytest.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from functools import partial, wraps
77
from six import iteritems as items
88

9+
from . import patch
910
from . import mock
1011

1112
sentinel = object()
@@ -61,6 +62,11 @@ def __call__(self, path, value=sentinel, name=None,
6162
self.monkeypatch.setattr(path, value)
6263
return value
6364

65+
def object(self, target, attribute, *args, **kwargs):
66+
return _wrap_context(
67+
patch.object(target, attribute, *args, **kwargs),
68+
self.request)
69+
6470
def _value_or_mock(self, value, new, name, path, **kwargs):
6571
if value is sentinel:
6672
value = new(name=name or path.rpartition('.')[2])

0 commit comments

Comments
 (0)