(self)
| 306 | # CRASHES setitemstring(NULL, b'a', 5) |
| 307 | |
| 308 | def test_dict_delitem(self): |
| 309 | # Test PyDict_DelItem() |
| 310 | delitem = _testlimitedcapi.dict_delitem |
| 311 | for dict_type in DICT_TYPES: |
| 312 | dct = dict_type({'a': 1, 'c': 2, '\U0001f40d': 3}) |
| 313 | delitem(dct, 'a') |
| 314 | self.assertEqual(dct, {'c': 2, '\U0001f40d': 3}) |
| 315 | self.assertRaises(KeyError, delitem, dct, 'b') |
| 316 | delitem(dct, '\U0001f40d') |
| 317 | self.assertEqual(dct, {'c': 2}) |
| 318 | |
| 319 | self.assertRaises(TypeError, delitem, {}, []) # unhashable |
| 320 | for test_type in FROZENDICT_TYPES: |
| 321 | with self.frozendict_does_not_support('deletion'): |
| 322 | delitem(test_type({'a': 1}), 'a') |
| 323 | for test_type in MAPPING_TYPES: |
| 324 | self.assertRaises(SystemError, delitem, test_type({'a': 1}), 'a') |
| 325 | for test_type in OTHER_TYPES: |
| 326 | self.assertRaises(SystemError, delitem, test_type(), 'a') |
| 327 | # CRASHES delitem({}, NULL) |
| 328 | # CRASHES delitem(NULL, 'a') |
| 329 | |
| 330 | def test_dict_delitemstring(self): |
| 331 | # Test PyDict_DelItemString() |
nothing calls this directly
no test coverage detected