(self)
| 543 | class TestHashMappingProtocol(TestMappingProtocol): |
| 544 | |
| 545 | def test_getitem(self): |
| 546 | TestMappingProtocol.test_getitem(self) |
| 547 | class Exc(Exception): pass |
| 548 | |
| 549 | class BadEq(object): |
| 550 | def __eq__(self, other): |
| 551 | raise Exc() |
| 552 | def __hash__(self): |
| 553 | return 24 |
| 554 | |
| 555 | d = self._empty_mapping() |
| 556 | d[BadEq()] = 42 |
| 557 | self.assertRaises(KeyError, d.__getitem__, 23) |
| 558 | |
| 559 | class BadHash(object): |
| 560 | fail = False |
| 561 | def __hash__(self): |
| 562 | if self.fail: |
| 563 | raise Exc() |
| 564 | else: |
| 565 | return 42 |
| 566 | |
| 567 | d = self._empty_mapping() |
| 568 | x = BadHash() |
| 569 | d[x] = 42 |
| 570 | x.fail = True |
| 571 | self.assertRaises(Exc, d.__getitem__, x) |
| 572 | |
| 573 | def test_fromkeys(self): |
| 574 | TestMappingProtocol.test_fromkeys(self) |
nothing calls this directly
no test coverage detected