def test_set_session_wrong_method(self):
    '\n        If `Connection.set_session` is passed a `Session` instance associated\n        with a context using a different SSL method than the `Connection`\n        is using, a `OpenSSL.SSL.Error` is raised.\n        '
    if (SSL_ST_INIT is None):
        v1 = TLSv1_2_METHOD
        v2 = TLSv1_METHOD
    elif hasattr(_lib, 'SSLv3_method'):
        v1 = TLSv1_METHOD
        v2 = SSLv3_METHOD
    else:
        pytest.skip('Test requires either OpenSSL 1.1.0 or SSLv3')
    key = load_privatekey(FILETYPE_PEM, server_key_pem)
    cert = load_certificate(FILETYPE_PEM, server_cert_pem)
    ctx = Context(v1)
    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

    def makeOriginalClient(socket):
        client = Connection(Context(v1), socket)
        client.set_connect_state()
        return client
    (originalServer, originalClient) = loopback(server_factory=makeServer, client_factory=makeOriginalClient)
    originalSession = originalClient.get_session()

    def makeClient(socket):
        client = Connection(Context(v2), socket)
        client.set_connect_state()
        client.set_session(originalSession)
        return client
    with pytest.raises(Error):
        loopback(client_factory=makeClient, server_factory=makeServer)
If `Connection.set_session` is passed a `Session` instance associated
with a context using a different SSL method than the `Connection`
is using, a `OpenSSL.SSL.Error` is raised.
def test_set_session_wrong_method(self):
    '\n        If `Connection.set_session` is passed a `Session` instance associated\n        with a context using a different SSL method than the `Connection`\n        is using, a `OpenSSL.SSL.Error` is raised.\n        '
    if (SSL_ST_INIT is None):
        v1 = TLSv1_2_METHOD
        v2 = TLSv1_METHOD
    elif hasattr(_lib, 'SSLv3_method'):
        v1 = TLSv1_METHOD
        v2 = SSLv3_METHOD
    else:
        pytest.skip('Test requires either OpenSSL 1.1.0 or SSLv3')
    key = load_privatekey(FILETYPE_PEM, server_key_pem)
    cert = load_certificate(FILETYPE_PEM, server_cert_pem)
    ctx = Context(v1)
    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

    def makeOriginalClient(socket):
        client = Connection(Context(v1), socket)
        client.set_connect_state()
        return client
    (originalServer, originalClient) = loopback(server_factory=makeServer, client_factory=makeOriginalClient)
    originalSession = originalClient.get_session()

    def makeClient(socket):
        client = Connection(Context(v2), socket)
        client.set_connect_state()
        client.set_session(originalSession)
        return client
    with pytest.raises(Error):
        loopback(client_factory=makeClient, server_factory=makeServer)