#NEWLINE# def test_index( self ) : #NEWLINE# #INDENT# u = self . type2test ( [ 0 , 1 ] ) #NEWLINE# self . assertEqual ( u . index ( 0 ) , 0 ) #NEWLINE# self . assertEqual ( u . index ( 1 ) , 1 ) #NEWLINE# self . assertRaises ( ValueError , u . index , 2 ) #NEWLINE# u = self . type2test ( [ ( - 2 ) , ( - 1 ) , 0 , 0 , 1 , 2 ] ) #NEWLINE# self . assertEqual ( u . count ( 0 ) , 2 ) #NEWLINE# self . assertEqual ( u . index ( 0 ) , 2 ) #NEWLINE# self . assertEqual ( u . index ( 0 , 2 ) , 2 ) #NEWLINE# self . assertEqual ( u . index ( ( - 2 ) , ( - 10 ) ) , 0 ) #NEWLINE# self . assertEqual ( u . index ( 0 , 3 ) , 3 ) #NEWLINE# self . assertEqual ( u . index ( 0 , 3 , 4 ) , 3 ) #NEWLINE# self . assertRaises ( ValueError , u . index , 2 , 0 , ( - 10 ) ) #NEWLINE# self . assertRaises ( TypeError , a . index ) #NEWLINE# class BadExc ( Exception ) : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# class BadCmp ( ) : #NEWLINE# #INDENT# def __eq__( self , other ) : #NEWLINE# #INDENT# if ( other == 2 ) : #NEWLINE# #INDENT# raise BadExc ( ) #NEWLINE# #UNINDENT# return False #NEWLINE# #UNINDENT# #UNINDENT# a = self . type2test ( [ 0 , 1 , 2 , 3 ] ) #NEWLINE# self . assertRaises ( BadExc , a . index , BadCmp ( ) ) #NEWLINE# a = self . type2test ( [ ( - 2 ) , ( - 1 ) , 0 , 0 , 1 , 2 ] ) #NEWLINE# self . assertEqual ( a . index ( 0 ) , 2 ) #NEWLINE# self . assertEqual ( a . index ( 0 , 2 ) , 2 ) #NEWLINE# self . assertEqual ( a . index ( 0 , ( - 4 ) ) , 2 ) #NEWLINE# self . assertEqual ( a . index ( ( - 2 ) , ( - 10 ) ) , 0 ) #NEWLINE# self . assertEqual ( a . index ( 0 , 3 ) , 3 ) #NEWLINE# self . assertEqual ( a . index ( 0 , ( - 3 ) ) , 3 ) #NEWLINE# self . assertEqual ( a . index ( 0 , 3 , 4 ) , 3 ) #NEWLINE# self . assertEqual ( a . index ( 0 , ( - 3 ) , ( - 2 ) ) , 3 ) #NEWLINE# self . assertEqual ( a . index ( 0 , ( ( - 4 ) * sys . maxsize ) , ( 4 * sys . maxsize ) ) , 2 ) #NEWLINE# self . assertRaises ( ValueError , a . index , 0 , ( 4 * sys . maxsize ) , ( ( - 4 ) * sys . maxsize ) ) #NEWLINE# self . assertRaises ( ValueError , a . index , 2 , 0 , ( - 10 ) ) #NEWLINE# a . remove ( 0 ) #NEWLINE# self . assertRaises ( ValueError , a . index , 2 , 0 , 4 ) #NEWLINE# self . assertEqual ( a , self . type2test ( [ ( - 2 ) , ( - 1 ) , 0 , 1 , 2 ] ) ) #NEWLINE# class EvilCmp ( ) : #NEWLINE# #INDENT# def __init__( self , victim ) : #NEWLINE# #INDENT# self . victim = victim #NEWLINE# #UNINDENT# def __eq__( self , other ) : #NEWLINE# #INDENT# del self . victim [ : ] #NEWLINE# return False #NEWLINE# #UNINDENT# #UNINDENT# a = self . type2test ( ) #NEWLINE# a [ : ] = [ EvilCmp ( a ) for _ in range ( 100 ) ] #NEWLINE# self . assertRaises ( ValueError , a . index , None )