mirror of
https://github.com/python/cpython.git
synced 2025-07-23 03:05:38 +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
|
@ -1198,6 +1198,15 @@ class MockTest(unittest.TestCase):
|
|||
m.assert_foo_call()
|
||||
m.assret_foo_call()
|
||||
|
||||
#Issue21262
|
||||
def test_assert_not_called(self):
|
||||
m = Mock()
|
||||
m.hello.assert_not_called()
|
||||
m.hello()
|
||||
with self.assertRaises(AssertionError):
|
||||
m.hello.assert_not_called()
|
||||
|
||||
|
||||
def test_mock_add_spec(self):
|
||||
class _One(object):
|
||||
one = 1
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue