def ll_list():
    """Sets up a linked list instance along with adds a few nodes for testing"""
    ll = LinkedList()
    ll.insert("a")
    ll.insert("b")
    ll.insert("c")
    return ll
def test_LinkedList_str():
    ll = LinkedList()
    ll.insert("a")
    ll.insert("b")
    actual = str(ll)
    expected = "{ b } -> { a } -> NULL"
    assert actual == expected
def test_LinkedList_kth_from_end_same_length():
    ll = LinkedList()
    ll.insert(2)
    ll.insert(8)
    actual = ll.kth_from_end(2)
    expected = 8
    assert actual == expected
def test_LinkedList_kth_from_end_ValueError_Exception():
    ll = LinkedList()
    ll.insert(2)
    ll.insert(8)
    ll.insert(3)
    ll.insert(1)
    with pytest.raises(ValueError):
        ll.kth_from_end(-6)
def test_LinkedList_kth_from_end_2():
    ll = LinkedList()
    ll.insert(2)
    ll.insert(8)
    ll.insert(3)
    ll.insert(1)
    actual = ll.kth_from_end(2)
    expected = 3
    assert actual == expected
def test_merge_list_list2_none():
    list1 = LinkedList()
    list2 = LinkedList()
    list1.insert("c")
    list1.insert("b")
    list1.insert("a")
    actual = str(merge_list(list1, list2))
    expected = "{ a } -> { b } -> { c } -> NULL"
    assert actual == expected
def test_merge_list_equal_lists():
    list1 = LinkedList()
    list2 = LinkedList()
    list1.insert("e")
    list1.insert("c")
    list1.insert("a")
    list2.insert("f")
    list2.insert("d")
    list2.insert("b")
    actual = str(merge_list(list1, list2))
    expected = "{ a } -> { b } -> { c } -> { d } -> { e } -> { f } -> NULL"
    assert actual == expected
def test_merge_list_list1_longer():
    list1 = LinkedList()
    list2 = LinkedList()
    list1.insert("3")
    list1.insert("1")
    list1.insert("4")
    list2.insert("9")
    list2.insert("5")
    actual = str(merge_list(list1, list2))
    expected = "{ 4 } -> { 5 } -> { 1 } -> { 9 } -> { 3 } -> NULL"
    assert actual == expected
def test_LinkedList_insert():
    ll = LinkedList()
    ll.insert("a")
    ll.insert("b")
    assert ll.head.value == "b"
    assert ll.head.next.value == "a"
def ll_list_merge():
    """Sets up two linked list instances along with some nodes for testing"""
    list1 = LinkedList()
    list1.insert("c")
    list1.insert("b")
    list1.insert("a")