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

Method test_dict_setitemstring

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

Source from the content-addressed store, hash-verified

286 # CRASHES setitem(NULL, 'a', 5)
287
288 def test_dict_setitemstring(self):
289 # Test PyDict_SetItemString()
290 setitemstring = _testlimitedcapi.dict_setitemstring
291 for dict_type in DICT_TYPES:
292 dct = dict_type()
293 setitemstring(dct, b'a', 5)
294 self.assertEqual(dct, {'a': 5})
295 setitemstring(dct, '\U0001f40d'.encode(), 8)
296 self.assertEqual(dct, {'a': 5, '\U0001f40d': 8})
297
298 self.assertRaises(UnicodeDecodeError, setitemstring, {}, INVALID_UTF8, 5)
299 for test_type in FROZENDICT_TYPES:
300 with self.frozendict_does_not_support('assignment'):
301 setitemstring(test_type(), b'a', 5)
302 for test_type in MAPPING_TYPES + OTHER_TYPES:
303 self.assertRaises(SystemError, setitemstring, test_type(), b'a', 5)
304 # CRASHES setitemstring({}, NULL, 5)
305 # CRASHES setitemstring({}, b'a', NULL)
306 # CRASHES setitemstring(NULL, b'a', 5)
307
308 def test_dict_delitem(self):
309 # Test PyDict_DelItem()

Callers

nothing calls this directly

Calls 4

assertEqualMethod · 0.45
encodeMethod · 0.45
assertRaisesMethod · 0.45

Tested by

no test coverage detected