diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2016-03-11 22:17:48 +0100 |
---|---|---|
committer | Robert Collins <rbtcollins@hp.com> | 2016-03-23 19:01:40 +1300 |
commit | 7ca5d3afe293d5e4d769c1cb2dfccb0688ba1292 (patch) | |
tree | aab79c55e4f745ea1a3224d4aba014f978a6a20b /mock/tests/testmock.py | |
parent | e966658bb362b3d70aad6e269abbf29a84ac5316 (diff) | |
download | mock-7ca5d3afe293d5e4d769c1cb2dfccb0688ba1292.tar.gz |
Add Mock.assert_called()
Issue #26323: Add assert_called() and assert_called_once() methods to
unittest.mock.Mock.
Diffstat (limited to 'mock/tests/testmock.py')
-rw-r--r-- | mock/tests/testmock.py | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/mock/tests/testmock.py b/mock/tests/testmock.py index 8ec9a60..7511c23 100644 --- a/mock/tests/testmock.py +++ b/mock/tests/testmock.py @@ -1288,6 +1288,27 @@ class MockTest(unittest.TestCase): with self.assertRaises(AssertionError): m.hello.assert_not_called() + def test_assert_called(self): + m = Mock() + with self.assertRaises(AssertionError): + m.hello.assert_called() + m.hello() + m.hello.assert_called() + + m.hello() + m.hello.assert_called() + + def test_assert_called_once(self): + m = Mock() + with self.assertRaises(AssertionError): + m.hello.assert_called_once() + m.hello() + m.hello.assert_called_once() + + m.hello() + with self.assertRaises(AssertionError): + m.hello.assert_called_once() + #Issue21256 printout of keyword args should be in deterministic order def test_sorted_call_signature(self): m = Mock() |