Exemplo n.º 1
0
def test_initialized_empty():
    pl = PathList()
    assert len(pl) == 0
    assert pl == []
    assert "a" not in pl
    assert pl.count("") == 0
    with pytest.raises(ValueError):
        pl.index(None)
    with pytest.raises(IndexError):
        _ = pl[1]

    for x in pl:
        assert False
Exemplo n.º 2
0
def test_list_access():
    pl = PathList([1, 2, 3])
    assert 1 in pl
    assert 3 in pl
    assert pl == [1, 2, 3]
    assert pl[0] == 1
    assert pl[2] == 3
    assert pl.count(1) == 1
    assert pl[:2] == [1, 2]
    assert pl[1:] == [2, 3]
    assert pl[:] == [1, 2, 3]
    assert pl[1:2] == [2]
    assert pl[::2] == [1, 3]
    assert pl[-1] == 3
    assert pl[-2:] == [2, 3]