MCPcopy Index your code
hub / github.com/python/cpython / reset_mock

Method reset_mock

Lib/unittest/mock.py:638–667  ·  view source on GitHub ↗

Restore the mock object to its initial state.

(self, visited=None, *,
                   return_value: bool = False,
                   side_effect: bool = False)

Source from the content-addressed store, hash-verified

636
637
638 def reset_mock(self, visited=None, *,
639 return_value: bool = False,
640 side_effect: bool = False):
641 "Restore the mock object to its initial state."
642 if visited is None:
643 visited = []
644 if id(self) in visited:
645 return
646 visited.append(id(self))
647
648 self.called = False
649 self.call_args = None
650 self.call_count = 0
651 self.mock_calls = _CallList()
652 self.call_args_list = _CallList()
653 self.method_calls = _CallList()
654
655 if return_value:
656 self._mock_return_value = DEFAULT
657 if side_effect:
658 self._mock_side_effect = None
659
660 for child in self._mock_children.values():
661 if isinstance(child, _SpecState) or child is _deleted:
662 continue
663 child.reset_mock(visited, return_value=return_value, side_effect=side_effect)
664
665 ret = self._mock_return_value
666 if _is_instance_mock(ret) and ret is not self:
667 ret.reset_mock(visited)
668
669
670 def configure_mock(self, /, **kwargs):

Callers

nothing calls this directly

Calls 6

idFunction · 0.85
_CallListClass · 0.85
_is_instance_mockFunction · 0.85
appendMethod · 0.45
valuesMethod · 0.45
reset_mockMethod · 0.45

Tested by

no test coverage detected