'Utility function that compares correct and real responses.'

def _check_response(self, response_contents, correct_jsons):

    for (username, content) in response_contents.items():
        keys_to_compare = set(content.keys()).difference(set(['top_words']))
        self.assertDictEqual({k: content[k] for k in keys_to_compare}, {k: correct_jsons[username][k] for k in keys_to_compare})
        top_words_content = sorted(content['top_words'], key=itemgetter('text'))
        top_words_correct = sorted(correct_jsons[username]['top_words'], key=itemgetter('text'))
        self.assertListEqual(top_words_content, top_words_correct)
