def test_pushpop_already_present(self) -> None: """Test pushpop method when the item is already present in the heap.""" heap = ExtHeapQueue() heap.push(3.3, "33") with pytest.raises( ValueError, match="the given item is already present in the heap"): heap.pushpop(3.3, "33")
def test_pushpop_empty(self) -> None: """Test pushpop method when the heap is empty.""" heap = ExtHeapQueue() assert heap.pushpop(1.0, 1) == 1 heap.push(2.0, 2) heap.remove(2) assert heap.pushpop(3.0, 3) == 3 heap.push(4.0, 4) heap.pop() assert heap.pushpop(5.0, 5) == 5
def test_pushpop(self) -> None: """Test pushpop method.""" heap = ExtHeapQueue() heap.push(1.0, "1") assert heap.pushpop(2.0, "2") == "1" assert heap.pushpop(0.0, "0") == "0" assert heap.pop() == "2"
def test_pushpop_refcount_saved(self) -> None: """Test manipulation with reference counter on pushpop - the item is stored in heap.""" heap = ExtHeapQueue() a1 = "zzzz" a2 = "fooo" heap.push(1.0, a1) assert heap.pushpop(0.1, a2) == a2 assert heap.get_top() == a1 assert heap.pop() == a1
def test_pushpop_refcount(self) -> None: """Test manipulation with reference counter on pushpop - compare with the standard heapq.""" heap = ExtHeapQueue() a = "foo_pushpop_1" heap.pushpop(1.0, a)