예제 #1
0
 def match(self, actual):
     filtered_expected = helpers.dict_subtract(self.expected,
                                               self.excluded_keys)
     filtered_actual = helpers.dict_subtract(actual,
                                             self.excluded_keys)
     if filtered_actual != filtered_expected:
         return DictMismatch(filtered_expected, filtered_actual)
예제 #2
0
 def describe(self):
     msg = ""
     if self.symmetric_diff:
         only_expected = helpers.dict_subtract(self.expected, self.actual)
         only_actual = helpers.dict_subtract(self.actual, self.expected)
         if only_expected:
             msg += "Only in expected:\n  %s\n" % self._format_dict(
                 only_expected)
         if only_actual:
             msg += "Only in actual:\n  %s\n" % self._format_dict(
                 only_actual)
     diff_set = set(o for o in self.intersect if
                    self.expected[o] != self.actual[o])
     if diff_set:
         msg += "Differences:\n"
         for o in diff_set:
             msg += "  %s: expected %s, actual %s\n" % (
                 o, self.expected[o], self.actual[o])
     return msg