def test_insert(elements): rlist = cows.List() for element in elements: rlist.insert(0, element) assert list(rlist) == list(reversed(elements))
def test_extend(elements): rlist = cows.List() rlist.extend(elements) rlist.extend(elements) assert list(rlist) == elements * 2
def test_index(elements): rlist = cows.List([e[0] for e in elements]) for element, correct_idxs in elements: assert rlist.index(element) in correct_idxs with pytest.raises(ValueError): rlist.index('XXX') # start param coverage for element, correct_idxs in elements: assert rlist.index(element, 1) in correct_idxs # start param coverage for element, correct_idxs in elements: assert rlist.index(element, end=4) in correct_idxs
def test_repr(): rlist = cows.List(['A', 'B', 'C']) assert rlist.__repr__() == 'cows.List([\'A\', \'B\', \'C\'])'
def test_reverse(elements): rlist = cows.List(elements) rlist.reverse() assert list(rlist) == list(reversed(elements))
def test_contains(elements): rlist = cows.List(elements) for element in elements: assert element in rlist assert 'XXXXXX' not in rlist
def test_count(elements): rlist = cows.List([e[0] for e in elements]) for element, correct_cnt in elements: assert rlist.count(element) == correct_cnt
def test_append(elements): rlist = cows.List() for element in elements: rlist.append(element) assert list(rlist) == elements
def test_initialize(elements): rlist = cows.List(elements) assert list(rlist) == elements