#NEWLINE# def test_access( ) : #NEWLINE# #INDENT# pairs = ( ( 'l_0_i' , '10' ) , ( 'l_1_i' , '11' ) , ( 'l_2_i' , '12' ) ) #NEWLINE# schema = List . named ( 'l' ) . of ( Integer . named ( 'i' ) ) #NEWLINE# el = schema . from_flat ( pairs ) #NEWLINE# elements = list ( ( Integer . named ( 'i' ) ( val ) for val in ( '10' , '11' , '12' ) ) ) #NEWLINE# assert ( len ( el ) == 3 ) #NEWLINE# assert ( el [ 0 ] == elements [ 0 ] ) #NEWLINE# assert ( el [ 1 ] == elements [ 1 ] ) #NEWLINE# assert ( el [ 2 ] == elements [ 2 ] ) #NEWLINE# assert ( el [ 0 ] . value == 10 ) #NEWLINE# assert ( el [ : 0 ] == elements [ : 0 ] ) #NEWLINE# assert ( el [ : 1 ] == elements [ : 1 ] ) #NEWLINE# assert ( el [ 0 : 5 ] == elements [ 0 : 5 ] ) #NEWLINE# assert ( elements [ ( - 2 ) : ( - 1 ) ] == elements [ ( - 2 ) : ( - 1 ) ] ) #NEWLINE# assert ( el [ 0 ] in el ) #NEWLINE# assert ( elements [ 0 ] in el ) #NEWLINE# assert ( '10' in el ) #NEWLINE# assert ( 10 in el ) #NEWLINE# assert ( el . count ( elements [ 0 ] ) == 1 ) #NEWLINE# assert ( el . count ( '10' ) == 1 ) #NEWLINE# assert ( el . count ( 10 ) == 1 ) #NEWLINE# assert ( el . index ( elements [ 0 ] ) == 0 ) #NEWLINE# assert ( el . index ( '10' ) == 0 ) #NEWLINE# assert ( el . index ( 10 ) == 0 )