def test_enqueue(new_queue):
    """Test that unique enqueued item is dequeued after all other items."""
    val = make_unique_value()
    new_queue.instance.enqueue(val)
    for _ in range(new_queue.size):
        new_queue.instance.dequeue()
    assert new_queue.instance.dequeue() == val
def test_append_popleft(new_deque):
    """Test that unique appended item is popped after all other items."""
    val = make_unique_value()
    new_deque.instance.append(val)
    for _ in new_deque.sequence:
        new_deque.instance.popleft()
    assert new_deque.instance.popleft() == val
def test_push_shift(new_dll):
    """Test that unique pushed item is shifted after all other items."""
    val = make_unique_value()
    new_dll.instance.push(val)
    for _ in new_dll.sequence:
        new_dll.instance.shift()
    assert new_dll.instance.shift() == val
def test_insert_pop_bottom_priority(new_priorityq):
    """Test unique item insertd with low priority is popped last."""
    val = make_unique_value()
    priority = MIN_INT if MAX else MAX_INT
    new_priorityq.instance.insert(val, priority)
    for _ in new_priorityq.sorted_sequence:
        new_priorityq.instance.pop()
    assert new_priorityq.instance.pop() == val
예제 #5
0
def test_push(new_ll):
    """Test that unique pushed item is popped befire all other items."""
    val = make_unique_value()
    new_ll.instance.push(val)
    assert new_ll.instance.pop() == val
예제 #6
0
def test_remove_fake_node(new_ll):
    """Test that attempt to remove a node not in list raises an error."""
    val = make_unique_value()
    fake_node = Node(val)
    with pytest.raises(REMOVE_ERROR):
        new_ll.instance.remove(fake_node)
예제 #7
0
def test_search_not_present(new_ll):
    """Test what happens when searching for something not in the list."""
    val = make_unique_value()
    assert new_ll.instance.search(val) is None
def test_insert_pop_top_priority(new_priorityq):
    """Test unique item inserted with top priority is immediately popped."""
    val = make_unique_value()
    priority = MAX_INT if MAX else MIN_INT
    new_priorityq.instance.insert(val, priority)
    assert new_priorityq.instance.pop() == val
def test_appendleft_popleft(new_deque):
    """Test that unique appendlefted item is popped."""
    val = make_unique_value()
    new_deque.instance.appendleft(val)
    assert new_deque.instance.popleft() == val
def test_remove_error(new_dll):
    """Test remove throws ValueError when asked to remove a value not in DLL."""
    val = make_unique_value()
    with pytest.raises(new_dll.remove_error):
        new_dll.instance.remove(val)
def test_append_shift(new_dll):
    """Test that unique appended item is popped after all other items."""
    val = make_unique_value()
    new_dll.instance.append(val)
    assert new_dll.instance.shift() == val
def test_push_pop(new_dll):
    """Test that unique pushed item is popped."""
    val = make_unique_value()
    new_dll.instance.push(val)
    assert new_dll.instance.pop() == val