how to add a custom type to unittest.TestCase.assertEqual
If you would like your TestCase class to understand one of your custom types as if it were standard, use addTypeEqualityFunc to supply a custom comparison function.
def addTypeEqualityFunc(self, typeobj, function): """Add a type specific assertEqual style function to compare a type. This method is for useby TestCase subclasses that need toregister their own type equality functions to provide nicer error messages. Args: typeobj: The datatypetocall this functiononwhenbothvalues areof the same typein assertEqual(). function: The callable taking two arguments and an optional msg= argument that raises self.failureException with a useful error message when the two arguments arenot equal. """ self._type_equality_funcs[typeobj] = function