Example #1
0
def test_insert_empty():
    dll = Dll()
    dll.insert(500)
    assert dll.head.prev is None
    assert dll.head.next_node is None
    assert dll.head.value == 500
    assert dll.head is dll.tail
Example #2
0
def test_insert():
    dll = Dll()
    dll.insert(500)
    first_node = dll.head
    dll.insert(600)
    assert dll.head.next_node is first_node
    assert dll.head.prev is None
    assert dll.head.value == 600
    assert dll.tail.prev is dll.head
Example #3
0
def test_remove_tail():
    dll = Dll()
    dll.insert(500)
    dll.insert(600)
    dll.insert(700)
    dll.remove(500)
    assert dll.tail.value == 600
    assert dll.tail.prev is dll.head
    assert dll.tail.next_node is None
Example #4
0
def test_remove():
    dll = Dll()
    dll.insert(500)
    dll.insert(600)
    back = dll.head
    dll.insert(700)
    dll.insert(800)
    front = dll.head
    dll.insert(900)
    dll.remove(700)
    assert back.prev is front
    assert front.next_node is back
Example #5
0
def test_remove_not_found():
    dll = Dll()
    dll.append(600)
    dll.insert(700)
    with pytest.raises(LookupError):
        dll.remove(500)