'Create the child mocks for attributes and return value.
By default child mocks will be the same type as the parent.
Subclasses of Mock may want to override this to customize the way
child mocks are made.
For non-callable mocks the callable variant will be used (rather than
any custom subclass).'

def _get_child_mock(self, **kw):

    _type = type(self)
    if (not issubclass(_type, CallableMixin)):
        if issubclass(_type, NonCallableMagicMock):
            klass = MagicMock
        elif issubclass(_type, NonCallableMock):
            klass = Mock
    else:
        klass = _type.__mro__[1]
    return klass(**kw)
