diff -r 2ecdda96f970 Doc/library/unittest.mock.rst --- a/Doc/library/unittest.mock.rst Tue Jul 10 18:27:54 2012 +0200 +++ b/Doc/library/unittest.mock.rst Tue Jul 10 23:05:40 2012 -0400 @@ -276,7 +276,7 @@ >>> mock.assert_called_once_with('foo', bar='baz') Traceback (most recent call last): ... - AssertionError: Expected to be called once. Called 2 times. + AssertionError: Expected 'mock' to be called once. Called 2 times. .. method:: assert_any_call(*args, **kwargs) @@ -2020,7 +2020,7 @@ >>> mock.assert_called_once_with(1, 2, 3) Traceback (most recent call last): ... - AssertionError: Expected to be called once. Called 2 times. + AssertionError: Expected 'mock' to be called once. Called 2 times. Because mocks auto-create attributes on demand, and allow you to call them with arbitrary arguments, if you misspell one of these assert methods then diff -r 2ecdda96f970 Lib/unittest/mock.py --- a/Lib/unittest/mock.py Tue Jul 10 18:27:54 2012 +0200 +++ b/Lib/unittest/mock.py Tue Jul 10 23:05:40 2012 -0400 @@ -731,8 +731,8 @@ arguments.""" self = _mock_self if not self.call_count == 1: - msg = ("Expected to be called once. Called %s times." % - self.call_count) + msg = ("Expected '%s' to be called once. Called %s times." % + (self._mock_name or 'mock', self.call_count)) raise AssertionError(msg) return self.assert_called_with(*args, **kwargs)