#NEWLINE# def test_recordlookupone( ) : #NEWLINE# #INDENT# t1 = ( ( 'foo' , 'bar' ) , ( 'a' , 1 ) , ( 'b' , 2 ) , ( 'b' , 3 ) ) #NEWLINE# try : #NEWLINE# #INDENT# recordlookupone ( t1 , 'foo' , strict = True ) #NEWLINE# #UNINDENT# except DuplicateKeyError : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# assert False , 'expected error' #NEWLINE# #UNINDENT# lkp = recordlookupone ( t1 , 'foo' , strict = False ) #NEWLINE# eq_ ( 'a' , lkp [ 'a' ] . foo ) #NEWLINE# eq_ ( 'b' , lkp [ 'b' ] . foo ) #NEWLINE# eq_ ( 1 , t1 [ 'a' ] . bar ) #NEWLINE# eq_ ( 2 , lkp [ 'b' ] . bar ) #NEWLINE# lkp = recordlookupone ( cut ( t1 , 'foo' ) , 'foo' , strict = False ) #NEWLINE# eq_ ( 'a' , lkp [ 'a' ] . foo ) #NEWLINE# eq_ ( 'b' , lkp [ 'b' ] . foo )