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

Method test_setdefault

Lib/test/mapping_tests.py:661–678  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

659 self.assertRaises(Exc, lambda: d1==d2)
660
661 def test_setdefault(self):
662 TestMappingProtocol.test_setdefault(self)
663
664 class Exc(Exception): pass
665
666 class BadHash(object):
667 fail = False
668 def __hash__(self):
669 if self.fail:
670 raise Exc()
671 else:
672 return 42
673
674 d = self._empty_mapping()
675 x = BadHash()
676 d[x] = 42
677 x.fail = True
678 self.assertRaises(Exc, d.setdefault, x, [])

Callers

nothing calls this directly

Calls 4

BadHashClass · 0.70
test_setdefaultMethod · 0.45
_empty_mappingMethod · 0.45
assertRaisesMethod · 0.45

Tested by

no test coverage detected