#NEWLINE# def test_diff_records_nonstr_values( self ) : #NEWLINE# #INDENT# lhs = [ { #NEWLINE# #INDENT# 'name' : 'a' , #NEWLINE# 'sheep' : 7 , #NEWLINE# #UNINDENT# } , { #NEWLINE# #INDENT# 'name' : 'b' , #NEWLINE# 'sheep' : 12 , #NEWLINE# #UNINDENT# } , { #NEWLINE# #INDENT# 'name' : 'c' , #NEWLINE# 'sheep' : 0 , #NEWLINE# #UNINDENT# } ] #NEWLINE# rhs = [ { #NEWLINE# #INDENT# 'name' : 'a' , #NEWLINE# 'sheep' : 7 , #NEWLINE# #UNINDENT# } , { #NEWLINE# #INDENT# 'name' : 'c' , #NEWLINE# 'sheep' : 2 , #NEWLINE# #UNINDENT# } , { #NEWLINE# #INDENT# 'name' : 'd' , #NEWLINE# 'sheep' : 8 , #NEWLINE# #UNINDENT# } ] #NEWLINE# diff = csvdiff . diff_records ( lhs , rhs , [ 'name' ] ) #NEWLINE# assert patch . is_valid ( diff ) #NEWLINE# assert patch . is_typed ( diff ) #NEWLINE# self . assertEqual ( diff [ 'added' ] , [ { #NEWLINE# #INDENT# 'name' : 'd' , #NEWLINE# 'sheep' : 8 , #NEWLINE# #UNINDENT# } ] ) #NEWLINE# self . assertEqual ( rhs [ 'removed' ] , [ { #NEWLINE# #INDENT# 'name' : 'b' , #NEWLINE# 'sheep' : 12 , #NEWLINE# #UNINDENT# } ] ) #NEWLINE# self . assertEqual ( diff [ 'changed' ] , [ { #NEWLINE# #INDENT# 'key' : [ 'c' ] , #NEWLINE# 'fields' : { #NEWLINE# #INDENT# 'sheep' : { #NEWLINE# #INDENT# 'from' : 0 , #NEWLINE# 'to' : 2 , #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } ] ) #NEWLINE# patched = csvdiff . patch_records ( diff , lhs ) #NEWLINE# self . assertRecordsEqual ( rhs , patched )