summaryrefslogtreecommitdiff
path: root/Lib/test/test_heapq.py
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2007-02-19 04:08:43 +0000
committerRaymond Hettinger <python@rcn.com>2007-02-19 04:08:43 +0000
commit00166c5532fc7562c07383a0ae2985b3ffaf253a (patch)
tree6f9c77ecb9639ad781c83d22d63e8014a71d5a76 /Lib/test/test_heapq.py
parentd6fc72a5ae27048dae56c773896ccbd6152d9b9b (diff)
downloadcpython-git-00166c5532fc7562c07383a0ae2985b3ffaf253a.tar.gz
Add merge() function to heapq.
Diffstat (limited to 'Lib/test/test_heapq.py')
-rw-r--r--Lib/test/test_heapq.py10
1 files changed, 9 insertions, 1 deletions
diff --git a/Lib/test/test_heapq.py b/Lib/test/test_heapq.py
index e9f27982bc..b7c3ab2f12 100644
--- a/Lib/test/test_heapq.py
+++ b/Lib/test/test_heapq.py
@@ -1,6 +1,6 @@
"""Unittests for heapq."""
-from heapq import heappush, heappop, heapify, heapreplace, nlargest, nsmallest
+from heapq import heappush, heappop, heapify, heapreplace, merge, nlargest, nsmallest
import random
import unittest
from test import test_support
@@ -103,6 +103,14 @@ class TestHeap(unittest.TestCase):
heap_sorted = [heappop(heap) for i in range(size)]
self.assertEqual(heap_sorted, sorted(data))
+ def test_merge(self):
+ inputs = []
+ for i in xrange(random.randrange(5)):
+ row = sorted(random.randrange(1000) for j in range(random.randrange(10)))
+ inputs.append(row)
+ self.assertEqual(sorted(chain(*inputs)), list(merge(*inputs)))
+ self.assertEqual(list(merge()), [])
+
def test_nsmallest(self):
data = [(random.randrange(2000), i) for i in range(1000)]
for f in (None, lambda x: x[0] * 547 % 2000):