#NEWLINE# def test_dict_to_omd( self ) : #NEWLINE# #INDENT# def enter( path , key , value ) : #NEWLINE# #INDENT# if isinstance ( value , dict ) : #NEWLINE# #INDENT# return ( OMD ( ) , sorted ( value . items ( ) ) ) #NEWLINE# #UNINDENT# return default_enter ( path , key , value ) #NEWLINE# #UNINDENT# orig = [ { #NEWLINE# #INDENT# 'title' : 'Wild Palms' , #NEWLINE# 'ratings' : { #NEWLINE# #INDENT# 1 : 1 , #NEWLINE# 2 : 3 , #NEWLINE# 3 : 5 , #NEWLINE# 4 : 6 , #NEWLINE# 5 : 3 , #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } , { #NEWLINE# #INDENT# 'title' : 'Twin Peaks' , #NEWLINE# 'ratings' : { #NEWLINE# #INDENT# 1 : 3 , #NEWLINE# 2 : 2 , #NEWLINE# 3 : 8 , #NEWLINE# 4 : 12 , #NEWLINE# 5 : 15 , #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } ] #NEWLINE# remapped = remap ( orig , enter = enter ) #NEWLINE# assert ( remapped == orig ) #NEWLINE# assert isinstance ( remapped [ 0 ] , OMD ) #NEWLINE# assert isinstance ( remapped [ 0 ] [ 'ratings' ] , OMD ) #NEWLINE# assert isinstance ( remapped [ 1 ] , OMD ) #NEWLINE# assert isinstance ( orig [ 1 ] [ 'ratings' ] , OMD )