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

Method test_issue24667

Lib/test/test_ordered_dict.py:594–615  ·  view source on GitHub ↗

dict resizes after a certain number of insertion operations, whether or not there were deletions that freed up slots in the hash table. During fast node lookup, OrderedDict must correctly respond to all resizes, even if the current "size" is the same as the

(self)

Source from the content-addressed store, hash-verified

592 od.popitem()
593
594 def test_issue24667(self):
595 """
596 dict resizes after a certain number of insertion operations,
597 whether or not there were deletions that freed up slots in the
598 hash table. During fast node lookup, OrderedDict must correctly
599 respond to all resizes, even if the current "size" is the same
600 as the old one. We verify that here by forcing a dict resize
601 on a sparse odict and then perform an operation that should
602 trigger an odict resize (e.g. popitem). One key aspect here is
603 that we will keep the size of the odict the same at each popitem
604 call. This verifies that we handled the dict resize properly.
605 """
606 OrderedDict = self.OrderedDict
607
608 od = OrderedDict()
609 for c0 in '0123456789ABCDEF':
610 for c1 in '0123456789ABCDEF':
611 if len(od) == 4:
612 # This should not raise a KeyError.
613 od.popitem(last=False)
614 key = c0 + c1
615 od[key] = key
616
617 # Direct use of dict methods
618

Callers

nothing calls this directly

Calls 2

popitemMethod · 0.95
OrderedDictClass · 0.70

Tested by

no test coverage detected