#NEWLINE# @ pytest . mark . parametrize ( 'stream_id' , [ 3 , 1 ] ) #NEWLINE# def test_continuation_cannot_interleave_headers( self , frame_factory , stream_id ) : #NEWLINE# #INDENT# '\n        We cannot interleave a new headers block with a CONTINUATION sequence.\n        ' #NEWLINE# c = h2 . connection . H2Connection ( client_side = False ) #NEWLINE# c . initiate_connection ( ) #NEWLINE# c . receive_data ( frame_factory . preamble ( ) ) #NEWLINE# c . clear_outbound_data_buffer ( ) #NEWLINE# frames = self . _build_continuation_sequence ( headers = frames . example_request_headers , block_size = 5 , frame_factory = frame_factory ) #NEWLINE# assert ( len ( frames ) > 2 ) #NEWLINE# bogus_frame = frame_factory . build_headers_frame ( headers = self . example_request_headers , stream_id = stream_id , flags = [ 'END_STREAM' ] ) #NEWLINE# frames . insert ( ( len ( frames ) - 2 ) , bogus_frame ) #NEWLINE# data = b'' . join ( ( f . serialize ( ) for f in frames ) ) #NEWLINE# with pytest . raises ( h2 . exceptions . ProtocolError ) as e : #NEWLINE# #INDENT# c . receive_data ( data ) #NEWLINE# #UNINDENT# assert ( 'invalid frame' in str ( e . value ) . lower ( ) )