mirror of
https://github.com/python/cpython.git
synced 2025-07-29 06:05:00 +00:00
Closes Issue 21262: New method assert_not_called for Mock.
It raises AssertionError if the mock has been called.
This commit is contained in:
parent
8c14534df6
commit
8af9db3e4f
4 changed files with 34 additions and 0 deletions
|
@ -321,6 +321,20 @@ the `new_callable` argument to `patch`.
|
|||
>>> calls = [call(4), call(2), call(3)]
|
||||
>>> mock.assert_has_calls(calls, any_order=True)
|
||||
|
||||
.. method:: assert_not_called(*args, **kwargs)
|
||||
|
||||
Assert the mock was never called.
|
||||
|
||||
>>> m = Mock()
|
||||
>>> m.hello.assert_not_called()
|
||||
>>> obj = m.hello()
|
||||
>>> m.hello.assert_not_called()
|
||||
Traceback (most recent call last):
|
||||
...
|
||||
AssertionError: Expected 'hello' to not have been called. Called 1 times.
|
||||
|
||||
.. versionadded:: 3.5
|
||||
|
||||
|
||||
.. method:: reset_mock()
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue