Esempio n. 1
0
def test_picking_a_property_does_not_consume_pipe():
    Person = namedtuple('Person', ['age'])

    pipe = Pype((Person(n) for n in _123))

    next(iter(pipe.pick(Person.age)))

    assert tuple(pipe) == (Person(2), Person(3))
Esempio n. 2
0
def test_picks_items_elements_at_the_given_key():
    pipe = Pype(str(n) for n in _123)

    assert tuple(pipe.pick(0)) == ('1', '2', '3')
Esempio n. 3
0
def test_picks_items_property():
    Person = namedtuple('Person', ['age'])

    pipe = Pype((Person(11), Person(22), Person(33)))

    assert tuple(pipe.pick(Person.age)) == (11, 22, 33)
Esempio n. 4
0
def test_picking_a_key_does_not_consume_pipe():
    pipe = Pype(str(n) for n in _123)

    next(iter(pipe.pick(0)))

    assert tuple(pipe) == ('2', '3')