diff options
author | Kushal Das <kushaldas@gmail.com> | 2016-06-02 17:20:16 (GMT) |
---|---|---|
committer | Kushal Das <kushaldas@gmail.com> | 2016-06-02 17:20:16 (GMT) |
commit | 9cd39a170b4e65bd17ba853e87134000523c055a (patch) | |
tree | 1cee2737612f86431f0ccbe918c5e5468bc1521e /Doc | |
parent | e2e71685f34b7252f0832d3b1247685e63b5acf8 (diff) | |
download | cpython-9cd39a170b4e65bd17ba853e87134000523c055a.zip cpython-9cd39a170b4e65bd17ba853e87134000523c055a.tar.gz cpython-9cd39a170b4e65bd17ba853e87134000523c055a.tar.bz2 |
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.
Diffstat (limited to 'Doc')
-rw-r--r-- | Doc/library/unittest.mock.rst | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/Doc/library/unittest.mock.rst b/Doc/library/unittest.mock.rst index 2073f0f..f2ebf11 100644 --- a/Doc/library/unittest.mock.rst +++ b/Doc/library/unittest.mock.rst @@ -364,7 +364,7 @@ the *new_callable* argument to :func:`patch`. .. versionadded:: 3.5 - .. method:: reset_mock() + .. method:: reset_mock(*, return_value=False, side_effect=False) The reset_mock method resets all the call attributes on a mock object: @@ -376,12 +376,20 @@ the *new_callable* argument to :func:`patch`. >>> mock.called False + .. versionchanged:: 3.6 + Added two keyword only argument to the reset_mock function. + This can be useful where you want to make a series of assertions that reuse the same object. Note that :meth:`reset_mock` *doesn't* clear the return value, :attr:`side_effect` or any child attributes you have - set using normal assignment. Child mocks and the return value mock + set using normal assignment by default. In case you want to reset + *return_value* or :attr:`side_effect`, then pass the corresponding + parameter as ``True``. Child mocks and the return value mock (if any) are reset as well. + .. note:: *return_value*, and :attr:`side_effect` are keyword only + argument. + .. method:: mock_add_spec(spec, spec_set=False) |