Пример #1
0
def test_has_loop_circular_valid(one_four_ll):
    """
    test has loop with valid case of true circular
    """
    ll = LL([1, 2, 3, 4, 5, 6])
    ll.head._next._next = ll.head
    assert has_loop(ll) == True
Пример #2
0
def test_check_valid_iterable():
    """
    check if iterable valid
    """
    with pytest.raises(TypeError) as err:
        LL(2)

    assert str(err.value) == 'Invalid iterable'
Пример #3
0
def linked_list_dict():
    return LL({'a': 1, 'b': 2, 'c': 3})
def test_noniterable_as_argument():
    with pytest.raises(TypeError):
        LL(1234)
Пример #5
0
def test_noniterable_as_argument():
    """Test raises correct error when passed noniterable."""
    with pytest.raises(TypeError) as err:
        LL(1234)
    assert str(err.value) == 'Please pass an iterable.'
Пример #6
0
def test_insert_iterable():
    """test inserting iterable into linked list"""
    assert LL([1, 2, 3, 4])._size == 4
Пример #7
0
def large_ll():
    """Long linked list."""
    return LL([1, 2, 3, 4, 5, 6, 7, 8])
 def __init__(self, max_size=1024):
     """Instantiates a Hash Table"""
     self.max_size = max_size
     self.buckets = [LL() for _ in range(self.max_size)]
def small_ll():
    """fixture for short array"""
    return LL([1, 2, 3, 4])
Пример #10
0
 def setUp(self):
     self.list = LL()
def empty_ll():
    return LL()
def predefined_ll():
    return LL([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])
Пример #13
0
def linked_list_zip():
    return LL((9, 8, 7, 6))
Пример #14
0
def test_kthFromEnd_emp():
    return LL()
Пример #15
0
def linked_list_tuple():
    return LL((1, 2, 3))
Пример #16
0
 def __init__(self, data):
     """init"""
     self.linked_list = LL(LLN(data))
Пример #17
0
 def __init__(self, data):
     """initialization"""
     self.linked_list = LL(LLN(data))
def short_ll():
    """fixture for short array"""
    return LL([5, 6, 7, 8])
Пример #19
0
def second_small_ll():
    """Small linked list."""
    return LL([1, 2, 3, 4])
def long_ll():
    """fixture for long array"""
    return LL([11, 12, 13, 14, 15, 16])
Пример #21
0
def empty_ll():
    """Empty linked list."""
    return LL()
def empty_ll():
    """fixture for empty array"""
    return LL()
Пример #23
0
def test_merge_none(predefined_ll):
    """Merge with empty lists."""
    empty = LL([])
    assert merge_lists(empty, predefined_ll).val == 1
    assert merge_lists(predefined_ll, empty).val == 1
    assert merge_lists(empty, empty) is None
def predefined_ll():
    """Default linked list for use with tests."""
    return LL([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])
Пример #25
0
def test_has_loop_has_none(one_four_ll):
    """
    test has loop with valid case of false
    """
    assert has_loop(LL([1, 2, 3, 4])) == False
def predefined_ll_other():
    """Second linked list for use with tests."""
    return LL([10, 9, 8, 7, 6, 5, 4, 3, 2, 1])
def predefined_ll_short():
    """Shorter linked list for use with tests."""
    return LL([11, 12, 13, 14])
def empty_ll():
    """Empty linked list for use with tests."""
    return LL()
Пример #29
0
 def __init__(self, max_size=1024):
     self.max_size = max_size
     # self.buckets[LL()] * self.max_size
     self.buckets = [LL() for _ in range(self.max_size)]
Пример #30
0
def m_linked_ll():
    return LL([1, 'b', 2, 'd'])