Esempio n. 1
0
def test_coiter_throw():
    c = coiter(co_throwable())
    assert next(c) == 1
    e = ValueError()
    assert c.throw(e) is e

    d = coiter((1, 2, 3))
    with pytest.raises(ValueError) as exc:
        d.throw(e)
    assert exc.value is e

    f = coiter((1, 2, 3))
    with pytest.raises(ValueError) as exc:
        f.throw(ValueError, 'v')
    assert exc.value.args == ('v', )
Esempio n. 2
0
def test_coiter_throw():
    c = coiter(co_throwable())
    assert next(c) == 1
    e = ValueError()
    assert c.throw(e) is e

    d = coiter((1, 2, 3))
    with pytest.raises(ValueError) as exc:
        d.throw(e)
    assert exc.value is e

    f = coiter((1, 2, 3))
    with pytest.raises(ValueError) as exc:
        f.throw(ValueError, 'v')
    assert exc.value.args == ('v',)
Esempio n. 3
0
def test_coiter_close():
    c = coiter(gen())
    assert next(c) == 1
    c.close()
    assert tuple(c) == ()
Esempio n. 4
0
def test_coiter_iter():
    assert tuple(coiter((1, 2, 3))) == (1, 2, 3)
    it = coiter((1, 2, 3))
    for n in (1, 2, 3):
        assert it.send(None) == n
Esempio n. 5
0
def test_coiter_send():
    c = coiter(co())
    assert next(c) == 1
    for n in (2, 3):
        assert c.send(n) == n
Esempio n. 6
0
def test_coiter_close():
    c = coiter(gen())
    assert next(c) == 1
    c.close()
    assert tuple(c) == ()
Esempio n. 7
0
def test_coiter_iter():
    assert tuple(coiter((1, 2, 3))) == (1, 2, 3)
    it = coiter((1, 2, 3))
    for n in (1, 2, 3):
        assert it.send(None) == n
Esempio n. 8
0
def test_coiter_send():
    c = coiter(co())
    assert next(c) == 1
    for n in (2, 3):
        assert c.send(n) == n