#NEWLINE# def test_lengths_ram( self ) : #NEWLINE# #INDENT# s = fields . Schema ( f1 = fields . KEYWORD ( stored = True , scorable = True ) , f2 = fields . KEYWORD ( stored = True , scorable = True ) ) #NEWLINE# st = store . RamStorage ( ) #NEWLINE# ix = index . Index ( st , s , create = True ) #NEWLINE# w = writing . IndexWriter ( ix ) #NEWLINE# w . add_document ( f1 = 'A B C D E' , f2 = 'X Y Z' ) #NEWLINE# w . add_document ( f1 = 'B B B B C D D Q' , f2 = 'Q R S T' ) #NEWLINE# w . add_document ( f1 = 'D E F' , f2 = 'U V A B C D E' ) #NEWLINE# w . commit ( ) #NEWLINE# dr = ix . doc_reader ( ) #NEWLINE# ls1 = [ dr . doc_field_length ( i , 'f1' ) for i in xrange ( 0 , 3 ) ] #NEWLINE# ls2 = [ dr . doc_field_length ( i , 'f2' ) for i in xrange ( 0 , 3 ) ] #NEWLINE# self . assertEqual ( ix [ 0 ] [ 'f1' ] , 'A B C D E' ) #NEWLINE# self . assertEqual ( dr . doc_field_length ( 0 , 'f1' ) , 5 ) #NEWLINE# self . assertEqual ( dr . doc_field_length ( 1 , 'f1' ) , 8 ) #NEWLINE# self . assertEqual ( dr . doc_field_length ( 2 , 'f1' ) , 3 ) #NEWLINE# self . assertEqual ( dr . doc_field_length ( 0 , 'f2' ) , 3 ) #NEWLINE# self . assertEqual ( dr . doc_field_length ( 1 , 'f2' ) , 4 ) #NEWLINE# self . assertEqual ( dr . doc_field_length ( 2 , 'f2' ) , 7 ) #NEWLINE# self . assertEqual ( ix . field_length ( 'f1' ) , 16 ) #NEWLINE# self . assertEqual ( ix . field_length ( 'f2' ) , 14 )