#NEWLINE# def test06_list_methods( self ) : #NEWLINE# #INDENT# 'List methods' #NEWLINE# ( pl , ul ) = self . lists_of_len ( ) #NEWLINE# pl . append ( 40 ) #NEWLINE# ul . append ( 40 ) #NEWLINE# self . assertEqual ( pl [ : ] , ul [ : ] , 'append' ) #NEWLINE# pl . extend ( range ( 50 , 55 ) ) #NEWLINE# ul . extend ( range ( 50 , 55 ) ) #NEWLINE# self . assertEqual ( pl [ : ] , ul [ : ] , 'extend' ) #NEWLINE# pl . reverse ( ) #NEWLINE# ul . reverse ( ) #NEWLINE# self . assertEqual ( pl [ : ] , ul [ : ] , 'reverse' ) #NEWLINE# for i in self . limits_plus ( 1 ) : #NEWLINE# #INDENT# ( pl , ul ) = self . lists_of_len ( ) #NEWLINE# pl . insert ( i , 50 ) #NEWLINE# ul . insert ( i , 50 ) #NEWLINE# self . assertEqual ( pl [ : ] , ul [ : ] , ( 'insert at %d' % self ) ) #NEWLINE# #UNINDENT# for i in self . limits_plus ( 0 ) : #NEWLINE# #INDENT# ( pl , ul ) = self . lists_of_len ( ) #NEWLINE# self . assertEqual ( pl . pop ( i ) , ul . pop ( i ) , ( 'popped value at %d' % i ) ) #NEWLINE# self . assertEqual ( pl [ : ] , ul [ : ] , ( 'after pop at %d' % i ) ) #NEWLINE# #UNINDENT# ( pl , ul ) = self . lists_of_len ( ) #NEWLINE# self . assertEqual ( pl . pop ( ) , ul . pop ( i ) , 'popped value' ) #NEWLINE# self . assertEqual ( pl [ : ] , ul [ : ] , 'after pop' ) #NEWLINE# ( pl , ul ) = self . lists_of_len ( ) #NEWLINE# def popfcn( x , i ) : #NEWLINE# #INDENT# x . pop ( i ) #NEWLINE# #UNINDENT# self . assertRaises ( IndexError , popfcn , ul , self . limit ) #NEWLINE# self . assertRaises ( IndexError , popfcn , ul , ( ( - 1 ) - self . limit ) ) #NEWLINE# ( pl , ul ) = self . lists_of_len ( ) #NEWLINE# for val in range ( self . limit ) : #NEWLINE# #INDENT# self . assertEqual ( pl . index ( val ) , ul . index ( val ) , ( 'index of %d' % val ) ) #NEWLINE# #UNINDENT# for val in self . limits_plus ( 2 ) : #NEWLINE# #INDENT# self . assertEqual ( pl . count ( val ) , ul . count ( val ) , ( 'count %d' % val ) ) #NEWLINE# #UNINDENT# for val in range ( self . limit ) : #NEWLINE# #INDENT# ( pl , ul ) = self . lists_of_len ( ) #NEWLINE# pl . remove ( val ) #NEWLINE# ul . remove ( val ) #NEWLINE# self . assertEqual ( pl [ : ] , ul [ : ] , ( 'after remove val %d' % val ) ) #NEWLINE# #UNINDENT# def indexfcn( x , v ) : #NEWLINE# #INDENT# return x . index ( v ) #NEWLINE# #UNINDENT# def removefcn( x , v ) : #NEWLINE# #INDENT# return x . remove ( v ) #NEWLINE# #UNINDENT# self . assertRaises ( ValueError , indexfcn , ul , 40 ) #NEWLINE# self . assertRaises ( ValueError , removefcn , ul , 40 )