':py:obj:`Connection.set_session`, when used prior to a connection being
established, accepts a :py:class:`Session` instance and causes an
attempt to re-use the session it represents when the SSL handshake is
performed.'

def test_client_set_session(self):

    key = load_privatekey(FILETYPE_PEM, server_key_pem)
    cert = load_certificate(FILETYPE_PEM, server_cert_pem)
    ctx = Context(TLSv1_METHOD)
    ctx.use_privatekey(key)
    ctx.use_certificate(cert)
    ctx.set_session_id('unity-test')
    def makeServer(socket):
        server = Connection(ctx, socket)
        server.set_accept_state()
        return server
    (originalServer, originalClient) = self._loopback(serverFactory=makeServer)
    originalSession = originalClient.get_session()
    def makeClient(socket):
        client = self._loopbackClientFactory(socket)
        client.set_session(originalSession)
        return client
    (resumedServer, resumedClient) = self._loopback(serverFactory=makeServer, clientFactory=makeClient)
    self.assertEqual(originalServer.master_key(), resumedServer.master_key())
