summaryrefslogtreecommitdiffstats
path: root/Lib/unittest/mock.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/unittest/mock.py')
-rw-r--r--Lib/unittest/mock.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/Lib/unittest/mock.py b/Lib/unittest/mock.py
index 48e7dd0..6c00bc6 100644
--- a/Lib/unittest/mock.py
+++ b/Lib/unittest/mock.py
@@ -758,6 +758,14 @@ class NonCallableMock(Base):
else:
return _call
+ def assert_not_called(_mock_self, *args, **kwargs):
+ """assert that the mock was never called.
+ """
+ self = _mock_self
+ if self.call_count != 0:
+ msg = ("Expected '%s' to not have been called. Called %s times." %
+ (self._mock_name or 'mock', self.call_count))
+ raise AssertionError(msg)
def assert_called_with(_mock_self, *args, **kwargs):
"""assert that the mock was called with the specified arguments.