Ejemplo n.º 1
0
def test_insert(elements):
    rlist = cows.List()

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

    assert list(rlist) == list(reversed(elements))
Ejemplo n.º 2
0
def test_extend(elements):
    rlist = cows.List()

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

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

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

    assert list(rlist) == elements
Ejemplo n.º 9
0
def test_initialize(elements):
    rlist = cows.List(elements)
    assert list(rlist) == elements