Ejemplo n.º 1
0
def test_instanciate_with_iter_wrong_len():
    w, h = 4, 3
    values = list(range(w * h - 2))
    with pytest.raises(ValueError):
        mygrid = Grid.from_iter(w, h, values)
Ejemplo n.º 2
0
def test_instanciate_with_gen():
    w, h = 4, 3
    values = range(w * h)
    mygrid = Grid.from_iter(w, h, values)
    assert mygrid[0] == [0, 1, 2, 3]
    assert mygrid[1, :] == [1, 5, 9]
Ejemplo n.º 3
0
def test_instanciate_with_iter():
    w, h = 4, 3
    iterable = list(range(w * h))
    mygrid = Grid.from_iter(w, h, iterable)
    assert mygrid[0] == [0, 1, 2, 3]
    assert mygrid[1, :] == [1, 5, 9]