'Utility method to verify if two objects are copies of each others.'

def assert_is_copy(self, obj, objcopy, msg=None):

    if (msg is None):
        msg = '{!r}    is    not    a    copy    of    {!r}'.format(obj, objcopy)
    self.assertEqual(obj, objcopy, msg=msg)
    self.assertIs(type(obj), type(objcopy), msg=msg)
    if hasattr(obj, '__dict__'):
        self.assertDictEqual(obj.__dict__, objcopy.__dict__, msg=msg)
        self.assertIsNot(obj.__dict__, objcopy.__dict__, msg=msg)
    if hasattr(obj, '__slots__'):
        self.assertListEqual(obj.__slots__, objcopy.__slots__, msg=msg)
        for slot in obj.__slots__:
            self.assertEqual(hasattr(obj, slot), hasattr(objcopy, slot), msg=msg)
            self.assertEqual(getattr(obj, slot, None), getattr(objcopy, slot, None), msg=msg)
