diff options
author | Kushal Das <kushaldas@gmail.com> | 2014-04-16 20:06:14 (GMT) |
---|---|---|
committer | Kushal Das <kushaldas@gmail.com> | 2014-04-16 20:06:14 (GMT) |
commit | 8af9db3e4fa17fb7add3f904a19d816f7787ee1c (patch) | |
tree | 18ffd4eb5f027edb0648bd32088bb455ef2a3c59 /Doc/library/unittest.mock.rst | |
parent | 8c14534df6c7bd561fac31985fba60306e181265 (diff) | |
download | cpython-8af9db3e4fa17fb7add3f904a19d816f7787ee1c.zip cpython-8af9db3e4fa17fb7add3f904a19d816f7787ee1c.tar.gz cpython-8af9db3e4fa17fb7add3f904a19d816f7787ee1c.tar.bz2 |
Closes Issue 21262: New method assert_not_called for Mock.
It raises AssertionError if the mock has been called.
Diffstat (limited to 'Doc/library/unittest.mock.rst')
-rw-r--r-- | Doc/library/unittest.mock.rst | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/Doc/library/unittest.mock.rst b/Doc/library/unittest.mock.rst index e6ca908..4f58892 100644 --- a/Doc/library/unittest.mock.rst +++ b/Doc/library/unittest.mock.rst @@ -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() |