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

Method test_list_insert

Lib/test/test_capi/test_list.py:153–173  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

151
152
153 def test_list_insert(self):
154 # Test PyList_Insert()
155 insert = _testlimitedcapi.list_insert
156 lst = [1, 2, 3]
157 insert(lst, 0, 23)
158 self.assertEqual(lst, [23, 1, 2, 3])
159 insert(lst, -1, 22)
160 self.assertEqual(lst, [23, 1, 2, 22, 3])
161 insert(lst, PY_SSIZE_T_MIN, 1)
162 self.assertEqual(lst[0], 1)
163 insert(lst, len(lst), 123)
164 self.assertEqual(lst[-1], 123)
165 insert(lst, len(lst)-1, 124)
166 self.assertEqual(lst[-2], 124)
167 insert(lst, PY_SSIZE_T_MAX, 223)
168 self.assertEqual(lst[-1], 223)
169
170 self.assertRaises(SystemError, insert, (1, 2, 3), 1, 5)
171 self.assertRaises(SystemError, insert, {1: 2}, 1, 5)
172
173 # CRASHES insert(NULL, 1, 5)
174
175 def test_list_append(self):
176 # Test PyList_Append()

Callers

nothing calls this directly

Calls 3

insertFunction · 0.85
assertEqualMethod · 0.45
assertRaisesMethod · 0.45

Tested by

no test coverage detected