unittest.mock.Mock.reset_mock()

reset_mock()

The reset_mock method resets all the call attributes on a mock object:

>>> mock = Mock(return_value=None)
>>> mock('hello')
>>> mock.called
True
>>> mock.reset_mock()
>>> mock.called
False

This can be useful where you want to make a series of assertions that reuse the same object. Note that reset_mock() doesn’t clear the return value, side_effect or any child attributes you have set using normal assignment. Child mocks and the return value mock (if any) are reset as well.

doc_python
2016-10-07 17:46:10
Comments
Leave a Comment

Please login to continue.