示例#1
0
def test_peek(create_pq):
    """Ensures that peek raises an error when the priority queue
    is empty, and that it returns the right value when items are added.
    """
    pq = PriorityQueue()
    with pytest.raises(IndexError):
        pq.peek()
    pq = create_pq
    pq.insert(100, "This is so much fun!")
    assert pq.peek() == "This is so much fun!"
    assert pq.peek() != "This sucks"