def test_handshake_protocol_agreement(message, transport):
 best_proto = 'worse_proto'
 wanted_protos = ['best', 'chat', 'worse_proto']
 server_protos = 'worse_proto,chat'
 message.headers.extend(gen_ws_headers(server_protos)[0])
 (_, resp_headers, _, _, protocol) = do_handshake(message.method, message.headers, transport, protocols=wanted_protos)
 assert (protocol == best_proto)

def test_handshake_protocol_agreement ( message , transport ) : best_proto = 'worse_proto' wanted_protos = [ 'best' , 'chat' , 'worse_proto' ] server_protos = 'worse_proto,chat' message . headers . extend ( gen_ws_headers ( server_protos ) [ 0 ] ) ( _ , resp_headers , _ , _ , protocol ) = do_handshake ( message . method , message . headers , transport , protocols = wanted_protos ) assert ( protocol == best_proto )
tests if the right protocol is selected given multiple .