#NEWLINE# def test_chunk( ) : #NEWLINE# #INDENT# data_length = 1000 #NEWLINE# chunk_length = 7 #NEWLINE# data = list ( range ( data_length ) ) #NEWLINE# chunks = utils . chunk ( data , chunk_length ) #NEWLINE# assert isinstance ( chunks , collections . Iterable ) #NEWLINE# chunks = list ( chunks ) #NEWLINE# for ( i , chunk ) in enumerate ( chunks [ : ( - 1 ) ] ) : #NEWLINE# #INDENT# assert ( len ( chunk ) == 7 ) #NEWLINE# assert ( chunk == data [ ( i * chunk_length ) : ( ( i + 1 ) * chunk_length ) ] ) #NEWLINE# #UNINDENT# assert ( len ( chunks [ ( - 1 ) ] ) == ( data_length % chunk_length ) ) #NEWLINE# assert ( chunks [ ( - 1 ) ] == data [ ( ( i + 1 ) * chunk_length ) : ] )