#NEWLINE# def test_pop( self ) : #NEWLINE# #INDENT# pairs = [ ( 'c' , 1 ) , ( 'b' , 2 ) , ( 'a' , 3 ) , ( 'd' , 4 ) , ( 'e' , 5 ) , ( 'f' , 6 ) ] #NEWLINE# shuffle ( pairs ) #NEWLINE# od = OrderedDict ( pairs ) #NEWLINE# shuffle ( pairs ) #NEWLINE# while pairs : #NEWLINE# #INDENT# ( k , v ) = pairs . pop ( ) #NEWLINE# self . assertEqual ( od . pop ( k ) , v ) #NEWLINE# #UNINDENT# with self . assertRaises ( KeyError ) : #NEWLINE# #INDENT# od . pop ( 'xyz' ) #NEWLINE# #UNINDENT# self . assertEqual ( len ( od ) , 0 ) #NEWLINE# self . assertEqual ( od . pop ( k , 12345 ) , 12345 ) #NEWLINE# class Missing ( OrderedDict ) : #NEWLINE# #INDENT# def __missing__( self , key ) : #NEWLINE# #INDENT# return 0 #NEWLINE# #UNINDENT# #UNINDENT# m = Missing ( a = 1 ) #NEWLINE# self . assertEqual ( m . pop ( 'b' , 5 ) , 5 ) #NEWLINE# self . assertEqual ( m . pop ( 'a' , 6 ) , 1 ) #NEWLINE# self . assertEqual ( m . pop ( 'a' , 6 ) , 6 ) #NEWLINE# with self . assertRaises ( KeyError ) : #NEWLINE# #INDENT# m . pop ( 'a' )