From 8af9db3e4fa17fb7add3f904a19d816f7787ee1c Mon Sep 17 00:00:00 2001 From: Kushal Das Date: Thu, 17 Apr 2014 01:36:14 +0530 Subject: Closes Issue 21262: New method assert_not_called for Mock. It raises AssertionError if the mock has been called. --- Lib/unittest/test/testmock/testmock.py | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'Lib/unittest/test/testmock/testmock.py') diff --git a/Lib/unittest/test/testmock/testmock.py b/Lib/unittest/test/testmock/testmock.py index 59353a095b6..b65dc321cff 100644 --- a/Lib/unittest/test/testmock/testmock.py +++ b/Lib/unittest/test/testmock/testmock.py @@ -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 -- cgit v1.2.3