summaryrefslogtreecommitdiff
path: root/mock.py
diff options
context:
space:
mode:
authorMichael Foord <michael@voidspace.org.uk>2011-09-26 00:20:00 +0100
committerMichael Foord <michael@voidspace.org.uk>2011-09-26 00:20:00 +0100
commitb1d0aeee358e950806b6b81a982136f91bda12dc (patch)
tree07fbcfcaf8e91f24f6cbd2c999d07987117dcb0d /mock.py
parent0e488c7d7304f6d835b4707d4ab805ca43e97d79 (diff)
downloadmock-b1d0aeee358e950806b6b81a982136f91bda12dc.tar.gz
Calls to mocks attached as magic methods are recorded in mock calls
Diffstat (limited to 'mock.py')
-rw-r--r--mock.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/mock.py b/mock.py
index 6655fd7..3a162a2 100644
--- a/mock.py
+++ b/mock.py
@@ -765,6 +765,9 @@ class NonCallableMock(Base):
real = lambda *args, **kw: original(self, *args, **kw)
value = mocksignature(value, real, skipfirst=True)
else:
+ # only set _new_name and not name so that mock_calls is tracked
+ # but not method calls
+ _check_and_set_parent(self, value, None, name)
setattr(type(self), name, value)
elif name in _allowed_names:
pass
@@ -781,6 +784,10 @@ class NonCallableMock(Base):
# for magic methods that are still MagicProxy objects and
# not set on the instance itself
return
+ elif name in self._mock_children:
+ del self._mock_children[name]
+ return
+
return object.__delattr__(self, name)