def full_list(): new_list = DoubleLink([1, 2, 3]) return new_list
def test_multi_value_list_with_parens(): """Test that you can create a list with a string of parens.""" new_list = DoubleLink(')()()()') assert new_list.head.value == ')'
def test_create_empty_dll(): """Test whether we create an empty list.""" new_list = DoubleLink() assert new_list._length is 0
def test_create_one_value_list(): """Test that you can create list with one value.""" new_list = DoubleLink(')') assert new_list._length == 1
def balanced_list(): new_list = DoubleLink(')()()()(') return new_list
def test_create_list_raise_error(): """Test that TypeError is raised when you init with noniterable.""" with pytest.raises(TypeError): new_dll = DoubleLink(iterable=123456)
def test_balanced_tail_closed_returns_0(): """Test that a list with a closed tail returns 0.""" new_list = DoubleLink(')()(') assert new_list.tail.value == ')' assert new_list.balanced() == 0
def open_list(): new_list = DoubleLink(')(()(') return new_list
def test_balanced_tail_open(): """Test that a list with an open tail returns 1.""" new_list = DoubleLink('(()(') assert new_list.tail.value == '(' assert new_list.balanced() == 1
def test_balanced_empty_list(): """Test that an empty list returns a value error.""" new_list = DoubleLink() with pytest.raises(ValueError): new_list.balanced()
def broken_list(): new_list = DoubleLink(')())(') return new_list
def test_balanced_first_node_closed_paren(): """Check that balanced returns -1 when head is ')'.""" new_list = DoubleLink('()') assert new_list.balanced() == -1
def test_push_tail_node_empty_list(): """Test that when you push to an empty list, the head is also the tail.""" new_list = DoubleLink() new_list.push(15) assert new_list.tail.value == 15