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

Method test_dict_setitem

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

Source from the content-addressed store, hash-verified

266 yield
267
268 def test_dict_setitem(self):
269 # Test PyDict_SetItem()
270 setitem = _testlimitedcapi.dict_setitem
271 for dict_type in DICT_TYPES:
272 dct = dict_type()
273 setitem(dct, 'a', 5)
274 self.assertEqual(dct, {'a': 5})
275 setitem(dct, '\U0001f40d', 8)
276 self.assertEqual(dct, {'a': 5, '\U0001f40d': 8})
277
278 self.assertRaises(TypeError, setitem, {}, [], 5) # unhashable
279 for test_type in FROZENDICT_TYPES:
280 with self.frozendict_does_not_support('assignment'):
281 setitem(test_type(), 'a', 5)
282 for test_type in MAPPING_TYPES + OTHER_TYPES:
283 self.assertRaises(SystemError, setitem, test_type(), 'a', 5)
284 # CRASHES setitem({}, NULL, 5)
285 # CRASHES setitem({}, 'a', NULL)
286 # CRASHES setitem(NULL, 'a', 5)
287
288 def test_dict_setitemstring(self):
289 # Test PyDict_SetItemString()

Callers

nothing calls this directly

Calls 4

setitemFunction · 0.85
assertEqualMethod · 0.45
assertRaisesMethod · 0.45

Tested by

no test coverage detected