summaryrefslogtreecommitdiff
path: root/Lib/test/test_heapq.py
diff options
context:
space:
mode:
authorTim Peters <tim.peters@gmail.com>2002-08-02 19:41:54 +0000
committerTim Peters <tim.peters@gmail.com>2002-08-02 19:41:54 +0000
commita25920e3549933e4c6c158cc9490f3eaa883ec66 (patch)
treee425f726f6c1d77c31959d24ac38495751bd6671 /Lib/test/test_heapq.py
parent7a4a52d5b4ae868f02aac8a5ca6ad27564276e45 (diff)
downloadcpython-a25920e3549933e4c6c158cc9490f3eaa883ec66.tar.gz
check_invariant(): Use the same child->parent "formula" used by heapq.py.
Diffstat (limited to 'Lib/test/test_heapq.py')
-rw-r--r--Lib/test/test_heapq.py4
1 files changed, 2 insertions, 2 deletions
diff --git a/Lib/test/test_heapq.py b/Lib/test/test_heapq.py
index 016fd3af41..879899e35c 100644
--- a/Lib/test/test_heapq.py
+++ b/Lib/test/test_heapq.py
@@ -8,8 +8,8 @@ import random
def check_invariant(heap):
# Check the heap invariant.
for pos, item in enumerate(heap):
- parentpos = ((pos+1) >> 1) - 1
- if parentpos >= 0:
+ if pos: # pos 0 has no parent
+ parentpos = (pos-1) >> 1
verify(heap[parentpos] <= item)
def test_main():