diff -r 513ad970a2aa Lib/unittest/mock.py --- a/Lib/unittest/mock.py Tue Jan 14 12:27:44 2014 +0100 +++ b/Lib/unittest/mock.py Tue Jan 14 14:09:41 2014 +0100 @@ -495,8 +495,14 @@ side_effect = property(__get_side_effect, __set_side_effect) - def reset_mock(self): + def reset_mock(self, visited=None): "Restore the mock object to its initial state." + if visited is None: + visited = [] + if id(self) in visited: + return + visited.append(id(self)) + self.called = False self.call_args = None self.call_count = 0 @@ -507,11 +513,11 @@ for child in self._mock_children.values(): if isinstance(child, _SpecState): continue - child.reset_mock() + child.reset_mock(visited) ret = self._mock_return_value if _is_instance_mock(ret) and ret is not self: - ret.reset_mock() + ret.reset_mock(visited) def configure_mock(self, **kwargs):