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
def test_check_valid_iterable(): """ check if iterable valid """ with pytest.raises(TypeError) as err: LL(2) assert str(err.value) == 'Invalid iterable'
def linked_list_dict(): return LL({'a': 1, 'b': 2, 'c': 3})
def test_noniterable_as_argument(): with pytest.raises(TypeError): LL(1234)
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.'
def test_insert_iterable(): """test inserting iterable into linked list""" assert LL([1, 2, 3, 4])._size == 4
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])
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])
def linked_list_zip(): return LL((9, 8, 7, 6))
def test_kthFromEnd_emp(): return LL()
def linked_list_tuple(): return LL((1, 2, 3))
def __init__(self, data): """init""" self.linked_list = LL(LLN(data))
def __init__(self, data): """initialization""" self.linked_list = LL(LLN(data))
def short_ll(): """fixture for short array""" return LL([5, 6, 7, 8])
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])
def empty_ll(): """Empty linked list.""" return LL()
def empty_ll(): """fixture for empty array""" return LL()
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])
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()
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)]
def m_linked_ll(): return LL([1, 'b', 2, 'd'])