def dictDiff(da, db):
different = False<EOL>resultDict = dict()<EOL>resultDict['<STR_LIT>'] = set(da) - set(db)<EOL>if resultDict['<STR_LIT>']:<EOL><INDENT>different = True<EOL><DEDENT>resultDict['<STR_LIT>'] = set(db) - set(da)<EOL>if resultDict['<STR_LIT>']:<EOL><INDENT>different = True<EOL><DEDENT>resultDict['<STR_LIT>'] = []<EOL>for key in (set(da) - resultDict['<STR_LIT>']):<EOL><INDENT>comparisonResult = da[key] == db[key]<EOL>if isinstance(comparisonResult, bool):<EOL><INDENT>isEqual = comparisonResult<EOL><DEDENT>else:<EOL><INDENT>isEqual = comparisonResult.all()<EOL><DEDENT>if not isEqual:<EOL><INDENT>resultDict['<STR_LIT>'].append(key)<EOL>different = True<EOL><DEDENT><DEDENT>assert (((resultDict['<STR_LIT>'] or resultDict['<STR_LIT>'] or<EOL>resultDict['<STR_LIT>']) and different) or not different)<EOL>return resultDict if different else None<EOL>
Compares two python dictionaries at the top level and return differences

    da:             first dictionary
    db:             second dictionary

    Returns:        None if dictionaries test equal; otherwise returns a
                    dictionary as follows:
                    {
                      'inAButNotInB':
                          <sequence of keys that are in da but not in db>
                      'inBButNotInA':
                          <sequence of keys that are in db but not in da>
                      'differentValues':
                          <sequence of keys whose corresponding values differ
                           between da and db>
                    }