예제 #1
0
def test_insert(elements):
    rlist = cows.List()

    for element in elements:
        rlist.insert(0, element)

    assert list(rlist) == list(reversed(elements))
예제 #2
0
def test_extend(elements):
    rlist = cows.List()

    rlist.extend(elements)
    rlist.extend(elements)

    assert list(rlist) == elements * 2
예제 #3
0
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
예제 #4
0
def test_repr():
    rlist = cows.List(['A', 'B', 'C'])
    assert rlist.__repr__() == 'cows.List([\'A\', \'B\', \'C\'])'
예제 #5
0
def test_reverse(elements):
    rlist = cows.List(elements)
    rlist.reverse()
    assert list(rlist) == list(reversed(elements))
예제 #6
0
def test_contains(elements):
    rlist = cows.List(elements)
    for element in elements:
        assert element in rlist

    assert 'XXXXXX' not in rlist
예제 #7
0
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
예제 #8
0
def test_append(elements):
    rlist = cows.List()
    for element in elements:
        rlist.append(element)

    assert list(rlist) == elements
예제 #9
0
def test_initialize(elements):
    rlist = cows.List(elements)
    assert list(rlist) == elements