#NEWLINE# def test_camera_stream_frames_trunc_right( ) : #NEWLINE# #INDENT# camera = mock . Mock ( ) #NEWLINE# encoder = mock . Mock ( ) #NEWLINE# camera . _encoders = { #NEWLINE# #INDENT# 1 : encoder , #NEWLINE# #UNINDENT# } #NEWLINE# stream = PiCameraCircularIO ( camera , size = 10 ) #NEWLINE# frames = [ ] #NEWLINE# for ( data , frame ) in generate_frames ( 'hkffkff' ) : #NEWLINE# #INDENT# encoder . frame = frame #NEWLINE# if frame . complete : #NEWLINE# #INDENT# frames . append ( frame ) #NEWLINE# #UNINDENT# stream . write ( data ) #NEWLINE# #UNINDENT# stream . seek ( 7 ) #NEWLINE# stream . truncate ( ) #NEWLINE# del frames [ ( - 2 ) : ] #NEWLINE# assert ( stream . getvalue ( ) == b'hkkffkk' ) #NEWLINE# assert ( list ( stream . frames ) == frames ) #NEWLINE# assert ( list ( reversed ( stream . frames ) ) == frames [ : : ( - 1 ) ] )