def test_delete_all_when_heap_of_random_size(self): size = randint(3, 100) a = [randint(-100, 100) for _ in range(size)] h = MaxHeap(a) for _ in range(size): self.assertIsNone(h.delete(choice(a))) self.assertTrue(is_max_heap(h)) self.assertEqual(h.size, 0) self.assertTrue(h.is_empty())
def test_delete_when_elem_is_last(self): h = MaxHeap([3, 4]) self.assertIsNone(h.delete(4)) self.assertTrue(is_max_heap(h)) self.assertEqual(h.size, 1) self.assertFalse(h.is_empty())