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

Method test_hashing

Lib/test/test_weakref.py:953–966  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

951 self.assertRaises(TypeError, op, a, b)
952
953 def test_hashing(self):
954 # Alive weakrefs hash the same as the underlying object
955 x = Object(42)
956 y = Object(42)
957 a = weakref.ref(x)
958 b = weakref.ref(y)
959 self.assertEqual(hash(a), hash(42))
960 del x, y
961 gc.collect()
962 # Dead weakrefs:
963 # - retain their hash is they were hashed when alive;
964 # - otherwise, cannot be hashed.
965 self.assertEqual(hash(a), hash(42))
966 self.assertRaises(TypeError, hash, b)
967
968 @unittest.skipIf(is_wasi and Py_DEBUG, "requires deep stack")
969 def test_trashcan_16602(self):

Callers

nothing calls this directly

Calls 4

ObjectClass · 0.70
assertEqualMethod · 0.45
collectMethod · 0.45
assertRaisesMethod · 0.45

Tested by

no test coverage detected