summaryrefslogtreecommitdiff
path: root/Lib
diff options
context:
space:
mode:
Diffstat (limited to 'Lib')
-rw-r--r--Lib/difflib.py2
-rw-r--r--Lib/test/test_heapq.py8
2 files changed, 5 insertions, 5 deletions
diff --git a/Lib/difflib.py b/Lib/difflib.py
index 85a1c9cb70..529c78638c 100644
--- a/Lib/difflib.py
+++ b/Lib/difflib.py
@@ -705,7 +705,7 @@ def get_close_matches(word, possibilities, n=3, cutoff=0.6):
result.append((s.ratio(), x))
# Move the best scorers to head of list
- result = heapq.nlargest(result, n)
+ result = heapq.nlargest(n, result)
# Strip scores for the best n matches
return [x for score, x in result]
diff --git a/Lib/test/test_heapq.py b/Lib/test/test_heapq.py
index b6fec9f47a..4e535e9ddd 100644
--- a/Lib/test/test_heapq.py
+++ b/Lib/test/test_heapq.py
@@ -92,13 +92,13 @@ class TestHeap(unittest.TestCase):
def test_nsmallest(self):
data = [random.randrange(2000) for i in range(1000)]
- for i in (0, 1, 2, 10, 100, 400, 999, 1000, 1100):
- self.assertEqual(nsmallest(data, i), sorted(data)[:i])
+ for n in (0, 1, 2, 10, 100, 400, 999, 1000, 1100):
+ self.assertEqual(nsmallest(n, data), sorted(data)[:n])
def test_largest(self):
data = [random.randrange(2000) for i in range(1000)]
- for i in (0, 1, 2, 10, 100, 400, 999, 1000, 1100):
- self.assertEqual(nlargest(data, i), sorted(data, reverse=True)[:i])
+ for n in (0, 1, 2, 10, 100, 400, 999, 1000, 1100):
+ self.assertEqual(nlargest(n, data), sorted(data, reverse=True)[:n])
def test_main(verbose=None):
test_classes = [TestHeap]