def test_pushpop(self): heap = OrderHeap(reversed(ascii_lowercase), key=self.key) for u, l in reversed(list(zip(ascii_uppercase, ascii_lowercase))): popped_item = heap.pushpop(u) heap.check() self.assertEqual(l, popped_item) self.assertSetEqual(set(ascii_uppercase), set(heap))
def test_pushpop(self): heap = OrderHeap(reversed(ascii_lowercase), key=self.key) wanted = set(ascii_lowercase) not_wanted = set() for u, l in reversed(list(zip(ascii_uppercase, ascii_lowercase))): self.assertEqual(l, heap.pushpop(u)) wanted.add(u) wanted.remove(l) not_wanted.add(l) self.assertHeap(wanted, not_wanted, heap) self.assertHeap(ascii_uppercase, ascii_lowercase, heap)