def test_enqueue(data, result_one, result_two): """Test the enqueue method.""" test_list = que_.Queue() for i in data: test_list.enqueue(i) assert test_list.head.value == result_one assert test_list.tail.value == result_two
def test_len(data, result): """Test if list len is properly incremented.""" test_list = que_.Queue(data) assert test_list.__len__() == result test_list.enqueue("test_push") assert test_list.__len__() == result + 1 test_list.dequeue() assert test_list.__len__() == result
def test_peek(data, result_one): """Test the peek method.""" test_list = que_.Queue(data) assert test_list.peek() == result_one
def test_dequeue_empty(): """Test to ensure dequeue function returns an index error when the list is empty.""" test_list = que_.Queue() with pytest.raises(IndexError): test_list.dequeue()
def test_dequeue(data, result_one, result_two): """Test the dequeue method.""" test_list = que_.Queue(data) assert test_list.dequeue() == result_one assert test_list.dequeue() == result_two
def test_list_iterables(data, result_one): """Ensure enque only takes list or tuples.""" test_list = que_.Queue(data) assert len(test_list) == result_one
def test_list(data, result_one, result_two): """Ensure proper assignment.""" test_list = que_.Queue(data) assert test_list.head.value == result_one assert test_list.tail.value == result_two