(self)
| 183 | # CRASHES getitemstring(NULL, b'a') |
| 184 | |
| 185 | def test_dict_getitemref(self): |
| 186 | # Test PyDict_GetItemRef() |
| 187 | getitem = _testcapi.dict_getitemref |
| 188 | for dict_type in ANYDICT_TYPES: |
| 189 | dct = dict_type({'a': 1, '\U0001f40d': 2}) |
| 190 | self.assertEqual(getitem(dct, 'a'), 1) |
| 191 | self.assertIs(getitem(dct, 'b'), KeyError) |
| 192 | self.assertEqual(getitem(dct, '\U0001f40d'), 2) |
| 193 | |
| 194 | self.assertRaises(TypeError, getitem, {}, []) # unhashable |
| 195 | for test_type in NOT_ANYDICT_TYPES + OTHER_TYPES: |
| 196 | self.assertRaises(SystemError, getitem, test_type(), 'a') |
| 197 | # CRASHES getitem({}, NULL) |
| 198 | # CRASHES getitem(NULL, 'a') |
| 199 | |
| 200 | def test_dict_getitemstringref(self): |
| 201 | # Test PyDict_GetItemStringRef() |
nothing calls this directly
no test coverage detected