MCPcopy Create free account
hub / github.com/python/cpython / test_merge_stability

Method test_merge_stability

Lib/test/test_heapq.py:350–363  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

348 list(self.module.merge(iterable(), iterable()))
349
350 def test_merge_stability(self):
351 class Int(int):
352 pass
353 inputs = [[], [], [], []]
354 for i in range(20000):
355 stream = random.randrange(4)
356 x = random.randrange(500)
357 obj = Int(x)
358 obj.pair = (x, stream)
359 inputs[stream].append(obj)
360 for stream in inputs:
361 stream.sort()
362 result = [i.pair for i in self.module.merge(*inputs)]
363 self.assertEqual(result, sorted(result))
364
365 def test_nsmallest(self):
366 data = [(random.randrange(2000), i) for i in range(1000)]

Callers

nothing calls this directly

Calls 6

randrangeMethod · 0.80
IntClass · 0.70
appendMethod · 0.45
sortMethod · 0.45
mergeMethod · 0.45
assertEqualMethod · 0.45

Tested by

no test coverage detected