summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_heapq.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/test/test_heapq.py')
-rw-r--r--Lib/test/test_heapq.py24
1 files changed, 12 insertions, 12 deletions
diff --git a/Lib/test/test_heapq.py b/Lib/test/test_heapq.py
index 1916449..b652d41 100644
--- a/Lib/test/test_heapq.py
+++ b/Lib/test/test_heapq.py
@@ -104,20 +104,20 @@ class TestHeap(unittest.TestCase):
self.assertEqual(heap_sorted, sorted(data))
def test_nsmallest(self):
- data = [random.randrange(2000) for i in range(1000)]
- f = lambda x: x * 547 % 2000
- for n in (0, 1, 2, 10, 100, 400, 999, 1000, 1100):
- self.assertEqual(nsmallest(n, data), sorted(data)[:n])
- self.assertEqual(nsmallest(n, data, key=f),
- sorted(data, key=f)[:n])
+ data = [(random.randrange(2000), i) for i in range(1000)]
+ for f in (None, lambda x: x[0] * 547 % 2000):
+ for n in (0, 1, 2, 10, 100, 400, 999, 1000, 1100):
+ self.assertEqual(nsmallest(n, data), sorted(data)[:n])
+ self.assertEqual(nsmallest(n, data, key=f),
+ sorted(data, key=f)[:n])
def test_nlargest(self):
- data = [random.randrange(2000) for i in range(1000)]
- f = lambda x: x * 547 % 2000
- for n in (0, 1, 2, 10, 100, 400, 999, 1000, 1100):
- self.assertEqual(nlargest(n, data), sorted(data, reverse=True)[:n])
- self.assertEqual(nlargest(n, data, key=f),
- sorted(data, key=f, reverse=True)[:n])
+ data = [(random.randrange(2000), i) for i in range(1000)]
+ for f in (None, lambda x: x[0] * 547 % 2000):
+ for n in (0, 1, 2, 10, 100, 400, 999, 1000, 1100):
+ self.assertEqual(nlargest(n, data), sorted(data, reverse=True)[:n])
+ self.assertEqual(nlargest(n, data, key=f),
+ sorted(data, key=f, reverse=True)[:n])
#==============================================================================