def assertProtosEqual(self, m1, m2): d1 = ProtoMessageToDict(m1) d2 = ProtoMessageToDict(m2) for k, v in d1.iteritems(): if k not in d2: self.fail('Value for %s not present in m2' % k) elif v != d2[k]: self.fail('Values for %s differ: expected "%s", got "%s"' % (k, v, d2[k])) for k, v in d2.iteritems(): if k not in d1: self.fail('Value for %s not present in m1' % k)
def assertProtosEqual(self, expected, actual): d1 = ProtoMessageToDict(expected) d2 = ProtoMessageToDict(actual) msg = '' for k, v in d1.iteritems(): if k not in d2: msg += 'Value for %s not present in actual. \n' % k elif v != d2[k]: msg += 'Values for %s differ: expected "%s", actual "%s". \n' % (k, v, d2[k]) for k, v in d2.iteritems(): if k not in d1: msg += 'Value for %s not present in expected. \n' % k if msg: self.fail(msg)