Issue #21271: Adds new keyword only parameters in reset_mock call

We now have two keyword only parameters in the reset_mock function to
selectively reset the return_value or the side_effects, or both.
This commit is contained in:
Kushal Das 2016-06-02 10:20:16 -07:00
parent e2e71685f3
commit 9cd39a170b
4 changed files with 36 additions and 3 deletions

View file

@ -523,7 +523,7 @@ class NonCallableMock(Base):
side_effect = property(__get_side_effect, __set_side_effect)
def reset_mock(self, visited=None):
def reset_mock(self, visited=None,*, return_value=False, side_effect=False):
"Restore the mock object to its initial state."
if visited is None:
visited = []
@ -538,6 +538,11 @@ class NonCallableMock(Base):
self.call_args_list = _CallList()
self.method_calls = _CallList()
if return_value:
self._mock_return_value = DEFAULT
if side_effect:
self._mock_side_effect = None
for child in self._mock_children.values():
if isinstance(child, _SpecState):
continue