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

Method test_insort

Lib/test/test_bisect.py:236–258  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

234 )
235
236 def test_insort(self):
237 from random import shuffle
238 mod = self.module
239
240 # Invariant: As random elements are inserted in
241 # a target list, the targetlist remains sorted.
242 keyfunc = abs
243 data = list(range(-10, 11)) + list(range(-20, 20, 2))
244 shuffle(data)
245 target = []
246 for x in data:
247 mod.insort_left(target, x, key=keyfunc)
248 self.assertEqual(
249 sorted(target, key=keyfunc),
250 target
251 )
252 target = []
253 for x in data:
254 mod.insort_right(target, x, key=keyfunc)
255 self.assertEqual(
256 sorted(target, key=keyfunc),
257 target
258 )
259
260 def test_insort_keynotNone(self):
261 x = []

Callers

nothing calls this directly

Calls 2

listClass · 0.85
assertEqualMethod · 0.45

Tested by

no test coverage detected