def test_npn_advertise_error(self):
    '\n        Test that we can handle exceptions in the advertise callback. If\n        advertise fails no NPN is advertised to the client.\n        '
    select_args = []

    def advertise(conn):
        raise TypeError

    def select(conn, options):
        '\n            Assert later that no args are actually appended.\n            '
        select_args.append((conn, options))
        return b''
    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 (select_args == [])
Test that we can handle exceptions in the advertise callback. If
advertise fails no NPN is advertised to the client.
def test_npn_advertise_error(self):
    '\n        Test that we can handle exceptions in the advertise callback. If\n        advertise fails no NPN is advertised to the client.\n        '
    select_args = []

    def advertise(conn):
        raise TypeError

    def select(conn, options):
        '\n            Assert later that no args are actually appended.\n            '
        select_args.append((conn, options))
        return b
    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 (select_args == [])