diff -r 92b292d68104 Lib/unittest/mock.py --- a/Lib/unittest/mock.py Mon Sep 08 17:29:02 2014 -0400 +++ b/Lib/unittest/mock.py Tue Sep 09 19:18:37 2014 +0530 @@ -2035,6 +2035,14 @@ return _Call(name=name, parent=self, from_kall=False) + def count(self, *args, **kwargs): + return _Call(('count', args, kwargs)) + + + def index(self, *args, **kwargs): + return _Call(('index', args, kwargs)) + + def __repr__(self): if not self.from_kall: name = self.name or 'call' diff -r 92b292d68104 Lib/unittest/test/testmock/testmock.py --- a/Lib/unittest/test/testmock/testmock.py Mon Sep 08 17:29:02 2014 -0400 +++ b/Lib/unittest/test/testmock/testmock.py Tue Sep 09 19:18:37 2014 +0530 @@ -1213,6 +1213,16 @@ text = "call(daddy='hero', name='hello')" self.assertEqual(repr(m.hello.call_args), text) + #Issue21270 overrides tuple methods for mock.call objects + def test_override_tuple_methods(self): + c = call.count() + i = call.index(132,'hello') + m = Mock() + m.count() + m.index(132,"hello") + self.assertEqual(m.method_calls[0], c) + self.assertEqual(m.method_calls[1], i) + def test_mock_add_spec(self): class _One(object): one = 1 diff -r 92b292d68104 Misc/NEWS --- a/Misc/NEWS Mon Sep 08 17:29:02 2014 -0400 +++ b/Misc/NEWS Tue Sep 09 19:18:37 2014 +0530 @@ -132,6 +132,9 @@ Library ------- +- Issue #21270: We now override tuple methods in mock.call objects so that + they can be used as normal call attributes. + - Issue #16662: load_tests() is now unconditionally run when it is present in a package's __init__.py. TestLoader.loadTestsFromModule() still accepts use_load_tests, but it is deprecated and ignored. A new keyword-only