(self)
| 213 | # CRASHES getitemstring(NULL, b'a') |
| 214 | |
| 215 | def test_dict_getitemwitherror(self): |
| 216 | # Test PyDict_GetItemWithError() |
| 217 | getitem = _testlimitedcapi.dict_getitemwitherror |
| 218 | for dict_type in ANYDICT_TYPES: |
| 219 | dct = dict_type({'a': 1, '\U0001f40d': 2}) |
| 220 | self.assertEqual(getitem(dct, 'a'), 1) |
| 221 | self.assertIs(getitem(dct, 'b'), KeyError) |
| 222 | self.assertEqual(getitem(dct, '\U0001f40d'), 2) |
| 223 | |
| 224 | self.assertRaises(TypeError, getitem, {}, []) # unhashable |
| 225 | for test_type in NOT_ANYDICT_TYPES + OTHER_TYPES: |
| 226 | self.assertRaises(SystemError, getitem, [], 'a') |
| 227 | # CRASHES getitem({}, NULL) |
| 228 | # CRASHES getitem(NULL, 'a') |
| 229 | |
| 230 | def test_dict_contains(self): |
| 231 | # Test PyDict_Contains() |
nothing calls this directly
no test coverage detected