From: Tim Peters Date: Fri, 2 Aug 2002 19:41:54 +0000 (+0000) Subject: check_invariant(): Use the same child->parent "formula" used by heapq.py. X-Git-Tag: v2.3c1~4767 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=d2cf1ab0e27b3d794b28170fe745c84723209b86;p=thirdparty%2FPython%2Fcpython.git check_invariant(): Use the same child->parent "formula" used by heapq.py. --- diff --git a/Lib/test/test_heapq.py b/Lib/test/test_heapq.py index 016fd3af41ed..879899e35cac 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():