MCPcopy Index your code
hub / github.com/python/cpython / test_dict_delitem

Method test_dict_delitem

Lib/test/test_capi/test_dict.py:308–328  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

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()

Callers

nothing calls this directly

Calls 4

delitemFunction · 0.85
assertEqualMethod · 0.45
assertRaisesMethod · 0.45

Tested by

no test coverage detected