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

Method test_subclass_with_custom_hash

Lib/test/test_weakset.py:179–190  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

177 elem.set = WeakSet([elem])
178
179 def test_subclass_with_custom_hash(self):
180 # Bug #1257731
181 class H(WeakSet):
182 def __hash__(self):
183 return int(id(self) & 0x7fffffff)
184 s=H()
185 f=set()
186 f.add(s)
187 self.assertIn(s, f)
188 f.remove(s)
189 f.add(s)
190 f.discard(s)
191
192 def test_init(self):
193 s = WeakSet()

Callers

nothing calls this directly

Calls 6

setFunction · 0.85
assertInMethod · 0.80
HClass · 0.70
addMethod · 0.45
removeMethod · 0.45
discardMethod · 0.45

Tested by

no test coverage detected