def test_client_set_session(self):
    '\n        `Connection.set_session`, when used prior to a connection being\n        established, accepts a `Session` instance and causes an attempt to\n        re-use the session it represents when the SSL handshake is performed.\n        '
    key = load_privatekey(FILETYPE_PEM, server_key_pem)
    cert = load_certificate(FILETYPE_PEM, server_cert_pem)
    ctx = Context(TLSv1_2_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) = loopback(server_factory=makeServer)
    originalSession = originalClient.get_session()

    def makeClient(socket):
        client = loopback_client_factory(socket)
        client.set_session(originalSession)
        return client
    (resumedServer, resumedClient) = loopback(server_factory=makeServer, client_factory=makeClient)
    assert (originalServer.master_key() == resumedServer.master_key())
`Connection.set_session`, when used prior to a connection being
established, accepts a `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):
    '\n        `Connection.set_session`, when used prior to a connection being\n        established, accepts a `Session` instance and causes an attempt to\n        re-use the session it represents when the SSL handshake is performed.\n        '
    key = load_privatekey(FILETYPE_PEM, server_key_pem)
    cert = load_certificate(FILETYPE_PEM, server_cert_pem)
    ctx = Context(TLSv1_2_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) = loopback(server_factory=makeServer)
    originalSession = originalClient.get_session()

    def makeClient(socket):
        client = loopback_client_factory(socket)
        client.set_session(originalSession)
        return client
    (resumedServer, resumedClient) = loopback(server_factory=makeServer, client_factory=makeClient)
    assert (originalServer.master_key() == resumedServer.master_key())