def test_insert_min_heap(): heap = Heap() items = [KeyedItem(key=i) for i in range(10)] random_items = [item for item in items] random.shuffle(random_items) for item in random_items: heap.insert(item) for i in range(10): assert heap.extract_root() is items[i] assert heap.extract_root() is None
def test_delete_only_item(): heap = Heap() item = KeyedItem(key=0) heap.insert(item) heap.delete(item) assert heap.extract_root() is None