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

Method test_ordering

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

Source from the content-addressed store, hash-verified

936 self.assertEqual(a != d, a is not d)
937
938 def test_ordering(self):
939 # weakrefs cannot be ordered, even if the underlying objects can.
940 ops = [operator.lt, operator.gt, operator.le, operator.ge]
941 x = Object(1)
942 y = Object(1)
943 a = weakref.ref(x)
944 b = weakref.ref(y)
945 for op in ops:
946 self.assertRaises(TypeError, op, a, b)
947 # Same when dead.
948 del x, y
949 gc.collect()
950 for op in ops:
951 self.assertRaises(TypeError, op, a, b)
952
953 def test_hashing(self):
954 # Alive weakrefs hash the same as the underlying object

Callers

nothing calls this directly

Calls 3

ObjectClass · 0.70
assertRaisesMethod · 0.45
collectMethod · 0.45

Tested by

no test coverage detected