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

Method test_dict_getitemref

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

Source from the content-addressed store, hash-verified

183 # CRASHES getitemstring(NULL, b'a')
184
185 def test_dict_getitemref(self):
186 # Test PyDict_GetItemRef()
187 getitem = _testcapi.dict_getitemref
188 for dict_type in ANYDICT_TYPES:
189 dct = dict_type({'a': 1, '\U0001f40d': 2})
190 self.assertEqual(getitem(dct, 'a'), 1)
191 self.assertIs(getitem(dct, 'b'), KeyError)
192 self.assertEqual(getitem(dct, '\U0001f40d'), 2)
193
194 self.assertRaises(TypeError, getitem, {}, []) # unhashable
195 for test_type in NOT_ANYDICT_TYPES + OTHER_TYPES:
196 self.assertRaises(SystemError, getitem, test_type(), 'a')
197 # CRASHES getitem({}, NULL)
198 # CRASHES getitem(NULL, 'a')
199
200 def test_dict_getitemstringref(self):
201 # Test PyDict_GetItemStringRef()

Callers

nothing calls this directly

Calls 4

getitemFunction · 0.85
assertEqualMethod · 0.45
assertIsMethod · 0.45
assertRaisesMethod · 0.45

Tested by

no test coverage detected