#NEWLINE# def test_clone( self ) : #NEWLINE# #INDENT# moe = { #NEWLINE# #INDENT# 'name' : 'moe' , #NEWLINE# 'lucky' : [ 13 , 27 , 34 ] , #NEWLINE# #UNINDENT# } #NEWLINE# clone = _ . clone ( moe ) #NEWLINE# self . assertEqual ( clone [ 'name' ] , 'moe' , 'the clone as the attributes of the original' ) #NEWLINE# clone [ 'name' ] = 'curly' #NEWLINE# self . assertTrue ( ( ( clone [ 'name' ] == 'curly' ) and ( moe [ 'name' ] == 'moe' ) ) , 'clones can change shallow attributes without affecting the original' ) #NEWLINE# clone [ 'lucky' ] . append ( 101 ) #NEWLINE# self . assertEqual ( _ . last ( moe [ 'lucky' ] ) , 101 , 'changes to deep attributes are shared with the original' ) #NEWLINE# self . assertEqual ( _ . clone ( 1 ) , 1 , 'non objects should not be changed by clone' ) #NEWLINE# self . assertEqual ( _ . clone ( None ) , None , 'non objects should not be changed by clone' )