#NEWLINE# def test_batching( self ) : #NEWLINE# #INDENT# seq = xrange ( 19 ) #NEWLINE# previous_list = None #NEWLINE# for batchiter in batch ( seq , 3 ) : #NEWLINE# #INDENT# x = list ( batchiter ) #NEWLINE# self . assertEqual ( len ( x ) , ( 1 if ( x [ 0 ] == 18 ) else 3 ) ) #NEWLINE# if ( previous_list is None ) : #NEWLINE# #INDENT# self . assertEqual ( x [ 0 ] , 0 ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# self . assertEqual ( x [ 0 ] , ( previous_list [ ( - 1 ) ] + 1 ) ) #NEWLINE# #UNINDENT# previous_list = x