MCPcopy Index your code
hub / github.com/RustPython/RustPython / test_setitem_atomic_at_resize

Method test_setitem_atomic_at_resize

Lib/test/test_dict.py:522–541  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

520 self.assertEqual(hashed1.eq_count + hashed2.eq_count, 1)
521
522 def test_setitem_atomic_at_resize(self):
523 class Hashed(object):
524 def __init__(self):
525 self.hash_count = 0
526 self.eq_count = 0
527 def __hash__(self):
528 self.hash_count += 1
529 return 42
530 def __eq__(self, other):
531 self.eq_count += 1
532 return id(self) == id(other)
533 hashed1 = Hashed()
534 # 5 items
535 y = {hashed1: 5, 0: 0, 1: 1, 2: 2, 3: 3}
536 hashed2 = Hashed()
537 # 6th item forces a resize
538 y[hashed2] = []
539 self.assertEqual(hashed1.hash_count, 1)
540 self.assertEqual(hashed2.hash_count, 1)
541 self.assertEqual(hashed1.eq_count + hashed2.eq_count, 1)
542
543 def test_popitem(self):
544 # dict.popitem()

Callers

nothing calls this directly

Calls 2

HashedClass · 0.85
assertEqualMethod · 0.45

Tested by

no test coverage detected