#NEWLINE# def test_multivaluedict( self ) : #NEWLINE# #INDENT# d = MultiValueDict ( { #NEWLINE# #INDENT# 'name' : [ 'Adrian' , 'Simon' ] , #NEWLINE# 'position' : [ 'Developer' ] , #NEWLINE# #UNINDENT# } ) #NEWLINE# self . assertEqual ( self [ 'name' ] , 'Simon' ) #NEWLINE# self . assertEqual ( d . get ( 'name' ) , 'Simon' ) #NEWLINE# self . assertEqual ( d . getlist ( 'name' ) , [ 'Adrian' , 'Simon' ] ) #NEWLINE# self . assertEqual ( sorted ( six . iteritems ( d ) ) , [ ( 'name' , 'Simon' ) , ( 'position' , 'Developer' ) ] ) #NEWLINE# self . assertEqual ( sorted ( six . iterlists ( d ) ) , [ ( 'name' , [ 'Adrian' , 'Simon' ] ) , ( 'position' , [ 'Developer' ] ) ] ) #NEWLINE# with self . assertRaisesMessage ( MultiValueDictKeyError , 'lastname' ) : #NEWLINE# #INDENT# d . __getitem__ ( 'lastname' ) #NEWLINE# #UNINDENT# self . assertEqual ( d . get ( 'lastname' ) , None ) #NEWLINE# self . assertEqual ( d . get ( 'lastname' , 'nonexistent' ) , 'nonexistent' ) #NEWLINE# self . assertEqual ( d . getlist ( 'lastname' ) , [ ] ) #NEWLINE# self . assertEqual ( d . getlist ( 'doesnotexist' , [ 'Adrian' , 'Simon' ] ) , [ 'Adrian' , 'Simon' ] ) #NEWLINE# d . setlist ( 'lastname' , [ 'Holovaty' , 'Willison' ] ) #NEWLINE# self . assertEqual ( d . getlist ( 'lastname' ) , [ 'Holovaty' , 'Willison' ] ) #NEWLINE# self . assertEqual ( sorted ( six . itervalues ( d ) ) , [ 'Developer' , 'Simon' , 'Willison' ] )