'Attach a mock as an attribute of this one, replacing its name and
parent. Calls to the attached mock will be recorded in the
`method_calls` and `mock_calls` attributes of this one.'

def attach_mock(self, mock, attribute):

    mock._mock_parent = None
    mock._mock_new_parent = None
    mock._mock_name = ''
    mock._mock_new_name = None
    setattr(self, attribute, mock)
