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

Method test_dict_delitemstring

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

Source from the content-addressed store, hash-verified

328 # CRASHES delitem(NULL, 'a')
329
330 def test_dict_delitemstring(self):
331 # Test PyDict_DelItemString()
332 delitemstring = _testlimitedcapi.dict_delitemstring
333 for dict_type in DICT_TYPES:
334 dct = dict_type({'a': 1, 'c': 2, '\U0001f40d': 3})
335 delitemstring(dct, b'a')
336 self.assertEqual(dct, {'c': 2, '\U0001f40d': 3})
337 self.assertRaises(KeyError, delitemstring, dct, b'b')
338 delitemstring(dct, '\U0001f40d'.encode())
339 self.assertEqual(dct, {'c': 2})
340
341 self.assertRaises(UnicodeDecodeError, delitemstring, {}, INVALID_UTF8)
342 for test_type in FROZENDICT_TYPES:
343 with self.frozendict_does_not_support('deletion'):
344 delitemstring(test_type({'a': 1}), b'a')
345 for test_type in MAPPING_TYPES:
346 self.assertRaises(SystemError, delitemstring, test_type({'a': 1}), b'a')
347 for test_type in OTHER_TYPES:
348 self.assertRaises(SystemError, delitemstring, test_type(), b'a')
349 # CRASHES delitemstring({}, NULL)
350 # CRASHES delitemstring(NULL, b'a')
351
352 def test_dict_setdefault(self):
353 # Test PyDict_SetDefault()

Callers

nothing calls this directly

Calls 4

assertEqualMethod · 0.45
assertRaisesMethod · 0.45
encodeMethod · 0.45

Tested by

no test coverage detected