def compare_obj(test, obj, db_obj, subs=None, allow_missing=None, comparators=None):
 if (subs is None):
  subs = {}
 if (allow_missing is None):
  allow_missing = []
 if (comparators is None):
  comparators = {}
 for key in obj.fields:
  if ((key in allow_missing) and (not obj.obj_attr_is_set(key))):
   continue
  obj_val = getattr(obj, key)
  db_key = subs.get(key, key)
  db_val = db_obj[db_key]
  if isinstance(obj_val, datetime.datetime):
   obj_val = obj_val.replace(tzinfo=None)
  if (key in comparators):
   comparator = comparators[key]
   comparator(db_val, obj_val)
  else:
   test.assertEqual(db_val, obj_val)

def compare_obj ( test , obj , db_obj , subs = None , allow_missing = None , comparators = None ) : if ( subs is None ) : subs = { } if ( allow_missing is None ) : allow_missing = [ ] if ( comparators is None ) : comparators = { } for key in obj . fields : if ( ( key in allow_missing ) and ( not obj . obj_attr_is_set ( key ) ) ) : continue obj_val = getattr ( obj , key ) db_key = subs . get ( key , key ) db_val = db_obj [ db_key ] if isinstance ( obj_val , datetime . datetime ) : obj_val = obj_val . replace ( tzinfo = None ) if ( key in comparators ) : comparator = comparators [ key ] comparator ( db_val , obj_val ) else : test . assertEqual ( db_val , obj_val )
compare a novaobject and a dict-like database object .