MCPcopy Index your code
hub / github.com/python/cpython / assert_is_copy

Method assert_is_copy

Lib/test/pickletester.py:745–761  ·  view source on GitHub ↗

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

(self, obj, objcopy, msg=None)

Source from the content-addressed store, hash-verified

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):

Callers 15

test_load_from_data0Method · 0.95
test_load_from_data1Method · 0.95
test_load_from_data2Method · 0.95
test_load_from_data3Method · 0.95
test_load_from_data4Method · 0.95
test_maxint64Method · 0.95
test_misc_getMethod · 0.95
test_miscMethod · 0.80
test_unicodeMethod · 0.80

Calls 6

assertDictEqualMethod · 0.80
assertIsNotMethod · 0.80
assertListEqualMethod · 0.80
formatMethod · 0.45
assertEqualMethod · 0.45
assertIsMethod · 0.45

Tested by

no test coverage detected