Exemple #1
0
def test_pop(m_eq, m_lbh, m_hbl):
    # pop() an empty Priority_Queue.
    with pytest.raises(IndexError):
        m_eq.pop()
    # Low before high priority and high before low enqueued should not
    # affect the order of these when popped off
    for x in range(-1, -6, -1):
        assert m_lbh.pop() == x
        assert m_hbl.pop() == x
    for x in range(5):
        assert m_lbh.pop() == x
        assert m_hbl.pop() == x

    # Only high priority items in the list.
    q = Priority_Queue(2)
    q.insert('hey', 0)
    q.insert('last', 0)
    assert q.pop() == 'hey'
    assert q.pop() == 'last'
def pop_off_empty_queue():
    pq = Priority_Queue()
    with pytest.raises(IndexError):
        pq.pop()
def pop_off_empty_queue():
    pq = Priority_Queue()
    with pytest.raises(IndexError):
        pq.pop()