def test_execution_order(): L = [] for i in range(5): s = Stream() b = s.pluck(1) a = s.pluck(0) li = a.combine_latest(b, emit_on=a).sink_to_list() z = [(1, 'red'), (2, 'blue'), (3, 'green')] for zz in z: s.emit(zz) L.append((li, )) for ll in L: assert ll == L[0] L2 = [] for i in range(5): s = Stream() a = s.pluck(0) b = s.pluck(1) li = a.combine_latest(b, emit_on=a).sink_to_list() z = [(1, 'red'), (2, 'blue'), (3, 'green')] for zz in z: s.emit(zz) L2.append((li, )) for ll, ll2 in zip(L, L2): assert ll2 == L2[0] assert ll != ll2
def test_pluck(): a = Stream() L = a.pluck(1).sink_to_list() a.emit([1, 2, 3]) assert L == [2] a.emit([4, 5, 6, 7, 8, 9]) assert L == [2, 5] with pytest.raises(IndexError): a.emit([1])
def test_pluck_list(): a = Stream() L = a.pluck([0, 2]).sink_to_list() a.emit([1, 2, 3]) assert L == [(1, 3)] a.emit([4, 5, 6, 7, 8, 9]) assert L == [(1, 3), (4, 6)] with pytest.raises(IndexError): a.emit([1])