def test_npn_select_error(self):
    '\n        Test that we can handle exceptions in the select callback. If\n        select fails it should be fatal to the connection.\n        '
    advertise_args = []

    def advertise(conn):
        advertise_args.append((conn,))
        return [b'http/1.1', b'spdy/2']

    def select(conn, options):
        raise TypeError
    server_context = Context(TLSv1_METHOD)
    server_context.set_npn_advertise_callback(advertise)
    client_context = Context(TLSv1_METHOD)
    client_context.set_npn_select_callback(select)
    server_context.use_privatekey(load_privatekey(FILETYPE_PEM, server_key_pem))
    server_context.use_certificate(load_certificate(FILETYPE_PEM, server_cert_pem))
    server = Connection(server_context, None)
    server.set_accept_state()
    client = Connection(client_context, None)
    client.set_connect_state()
    with pytest.raises(TypeError):
        interact_in_memory(server, client)
    assert (advertise_args == [(server,)])
Test that we can handle exceptions in the select callback. If
select fails it should be fatal to the connection.
def test_npn_select_error(self):
    '\n        Test that we can handle exceptions in the select callback. If\n        select fails it should be fatal to the connection.\n        '
    advertise_args = []

    def advertise(conn):
        advertise_args.append((conn,))
        return [b'http/1.1', b'spdy/2']

    def select(conn, options):
        raise TypeError
    server_context = Context(TLSv1_METHOD)
    server_context.set_npn_advertise_callback(advertise)
    client_context = Context(TLSv1_METHOD)
    client_context.set_npn_select_callback(select)
    server_context.use_privatekey(load_privatekey(FILETYPE_PEM, server_key_pem))
    server_context.use_certificate(load_certificate(FILETYPE_PEM, server_cert_pem))
    server = Connection(server_context, None)
    server.set_accept_state()
    client = Connection(client_context, None)
    client.set_connect_state()
    with pytest.raises(TypeError):
        interact_in_memory(server, client)
    assert (advertise_args == [(server,)])