#NEWLINE# @ pytest . mark . parametrize ( 'end_stream' , ( True , False ) ) #NEWLINE# def test_receiving_out_of_order_headers( self , frame_factory , end_stream ) : #NEWLINE# #INDENT# '\n        When receiving a informational response after the actual response\n        headers we consider it a ProtocolError and raise it.\n        ' #NEWLINE# c = h2 . connection . H2Connection ( client_side = True ) #NEWLINE# c . initiate_connection ( ) #NEWLINE# c . send_headers ( stream_id = 1 , headers = self . example_request_headers , end_stream = end_stream ) #NEWLINE# f1 = frame_factory . build_headers_frame ( headers = self . example_response_headers , stream_id = 1 ) #NEWLINE# f2 = frame_factory . build_headers_frame ( headers = self . example_informational_headers , stream_id = 1 ) #NEWLINE# c . receive_data ( f1 . serialize ( ) ) #NEWLINE# c . clear_outbound_data_buffer ( ) #NEWLINE# with pytest . raises ( h2 . exceptions . ProtocolError ) : #NEWLINE# #INDENT# c . receive_data ( f2 . serialize ( ) ) #NEWLINE# #UNINDENT# expected = frame_factory . build_goaway_frame ( last_stream_id = 0 , error_code = 1 ) #NEWLINE# assert ( c . data_to_send ( ) == expected . serialize ( ) )