(self)
| 142 | self.assertRaises(SystemError, size, NULL) |
| 143 | |
| 144 | def test_dict_getitem(self): |
| 145 | # Test PyDict_GetItem() |
| 146 | getitem = _testlimitedcapi.dict_getitem |
| 147 | for dict_type in ANYDICT_TYPES: |
| 148 | dct = dict_type({'a': 1, '\U0001f40d': 2}) |
| 149 | self.assertEqual(getitem(dct, 'a'), 1) |
| 150 | self.assertIs(getitem(dct, 'b'), KeyError) |
| 151 | self.assertEqual(getitem(dct, '\U0001f40d'), 2) |
| 152 | |
| 153 | with support.catch_unraisable_exception() as cm: |
| 154 | self.assertIs(getitem({}, []), KeyError) # unhashable |
| 155 | self.assertEqual(cm.unraisable.exc_type, TypeError) |
| 156 | self.assertEqual(str(cm.unraisable.exc_value), |
| 157 | "unhashable type: 'list'") |
| 158 | |
| 159 | for test_type in NOT_ANYDICT_TYPES + OTHER_TYPES: |
| 160 | self.assertIs(getitem(test_type(), 'a'), KeyError) |
| 161 | |
| 162 | # CRASHES getitem({}, NULL) |
| 163 | # CRASHES getitem(NULL, 'a') |
| 164 | |
| 165 | def test_dict_getitemstring(self): |
| 166 | # Test PyDict_GetItemString() |
nothing calls this directly
no test coverage detected