Utility method to verify if two objects are copies of each others.
(self, obj, objcopy, msg=None)
| 743 | _testdata = create_data() |
| 744 | |
| 745 | def assert_is_copy(self, obj, objcopy, msg=None): |
| 746 | """Utility method to verify if two objects are copies of each others. |
| 747 | """ |
| 748 | if msg is None: |
| 749 | msg = "{!r} is not a copy of {!r}".format(obj, objcopy) |
| 750 | self.assertEqual(obj, objcopy, msg=msg) |
| 751 | self.assertIs(type(obj), type(objcopy), msg=msg) |
| 752 | if hasattr(obj, '__dict__'): |
| 753 | self.assertDictEqual(obj.__dict__, objcopy.__dict__, msg=msg) |
| 754 | self.assertIsNot(obj.__dict__, objcopy.__dict__, msg=msg) |
| 755 | if hasattr(obj, '__slots__'): |
| 756 | self.assertListEqual(obj.__slots__, objcopy.__slots__, msg=msg) |
| 757 | for slot in obj.__slots__: |
| 758 | self.assertEqual( |
| 759 | hasattr(obj, slot), hasattr(objcopy, slot), msg=msg) |
| 760 | self.assertEqual(getattr(obj, slot, None), |
| 761 | getattr(objcopy, slot, None), msg=msg) |
| 762 | |
| 763 | def check_unpickling_error_strict(self, errors, data): |
| 764 | with self.assertRaises(errors): |
no test coverage detected