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

Method test_clear_at_lookup

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

Source from the content-addressed store, hash-verified

1631 d.get(key2)
1632
1633 def test_clear_at_lookup(self):
1634 # gh-140551 dict crash if clear is called at lookup stage
1635 class X:
1636 def __hash__(self):
1637 return 1
1638 def __eq__(self, other):
1639 nonlocal d
1640 d.clear()
1641
1642 d = {}
1643 for _ in range(10):
1644 d[X()] = None
1645
1646 self.assertEqual(len(d), 1)
1647
1648 d = {}
1649 for _ in range(10):
1650 d.setdefault(X(), None)
1651
1652 self.assertEqual(len(d), 1)
1653
1654 def test_split_table_update_with_str_subclass(self):
1655 # gh-142218: inserting into a split table dictionary with a non str

Callers

nothing calls this directly

Calls 3

XClass · 0.70
assertEqualMethod · 0.45
setdefaultMethod · 0.45

Tested by

no test coverage detected