def __call__(self, *params, **named_params):
    """Provide custom logic for mocking classes that are callable."""

    # Verify the class we are mocking is callable
    callable = self._class_to_mock.__dict__.get('__call__', None)
    if callable is None:
      raise TypeError('Not callable')

    # Because the call is happening directly on this object instead of a method,
    # the call on the mock method is made right here
    mock_method = self._CreateMockMethod('__call__')
    return mock_method(*params, **named_params)
Provide custom logic for mocking classes that are callable.
deps/protobuf/python/mox.py