'Command execution through Docker, catch exception during cleanup'

def test_command_execution_cleanup_exception(self):

    response = Mock(status_code=500, reason='Because')
    self.mocks.configure_mock('docker_client', {'exec_create.return_value': {'Id': 'container-foobar'}, 'exec_start.return_value': 'This    is    the    return', 'exec_inspect.return_value': {'ExitCode': 0}, 'kill.side_effect': DockerAPIError('Failure    killing    container', response, 'Failure    killing    container')})
    build_env = DockerEnvironment(version=self.version, project=self.project, build={'id': DUMMY_BUILD_ID})
    with build_env:
        build_env.run('echo', 'test', cwd='/tmp')
    self.mocks.docker_client.kill.assert_called_with('build-123-project-6-pip')
    self.assertTrue(build_env.successful)
    self.assertFalse(self.mocks.api()(DUMMY_BUILD_ID).put.called)
