#NEWLINE# def unorderable_list_difference( expected , actual , ignore_duplicate = False ) : #NEWLINE# #INDENT# 'Same behavior as sorted_list_difference but\n    for lists of unorderable items (like dicts).\n\n    As it does a linear search per item (remove) it\n    has O(n*n) performance.\n    ' #NEWLINE# missing = [ ] #NEWLINE# unexpected = [ ] #NEWLINE# while expected : #NEWLINE# #INDENT# item = expected . pop ( ) #NEWLINE# try : #NEWLINE# #INDENT# actual . remove ( item ) #NEWLINE# #UNINDENT# except ValueError : #NEWLINE# #INDENT# missing . append ( item ) #NEWLINE# #UNINDENT# if ignore_duplicate : #NEWLINE# #INDENT# for lst in ( expected , actual ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# while True : #NEWLINE# #INDENT# lst . remove ( item ) #NEWLINE# #UNINDENT# #UNINDENT# except ValueError : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# if ignore_duplicate : #NEWLINE# #INDENT# while actual : #NEWLINE# #INDENT# item = actual . pop ( ) #NEWLINE# unexpected . append ( item ) #NEWLINE# try : #NEWLINE# #INDENT# while True : #NEWLINE# #INDENT# actual . remove ( item ) #NEWLINE# #UNINDENT# #UNINDENT# except ValueError : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# #UNINDENT# return ( missing , unexpected ) #NEWLINE# #UNINDENT# return ( lst , actual )