

@mock.patch.object(cloud_config.CloudConfig, 'get_session')
def test_get_session_endpoint_exception(self, get_session_mock):

    class FakeException(Exception):
        pass

    def side_effect(*args, **kwargs):
        raise FakeException('No service')
    session_mock = mock.Mock()
    session_mock.get_endpoint.side_effect = side_effect
    get_session_mock.return_value = session_mock
    self.cloud.name = 'testcloud'
    self.cloud.region_name = 'testregion'
    with testtools.ExpectedException(exc.OpenStackCloudException, 'Error getting image endpoint on testcloud:testregion: No service'):
        session_mock.cloud.get_session_endpoint('image')

dataset/ETHPy150Open openstack-infra/shade/shade/tests/unit/test_shade_operator.py TestShadeOperator.test_get_session_endpoint_exception/VarMisuse@110/185 `self`->`session_mock`