コード例 #1
0
ファイル: dataflow_test.py プロジェクト: jmalbos/dataflow
def test_slice_downstream(spec):

    the_source = list('abcdefghij')
    result = []
    the_sink = df.sink(result.append)

    df.push(source=the_source, pipe=df.pipe(df.slice(*spec), the_sink))

    specslice = slice(*spec)
    assert result == the_source[specslice]
    assert result == the_source[specslice.start:specslice.stop:specslice.step]
コード例 #2
0
ファイル: dataflow_test.py プロジェクト: jmalbos/dataflow
def test_slice_close_all(close_all):
    the_source = list(range(20))
    n_elements = 5
    slice = df.slice(n_elements, close_all=close_all)

    result_branch = []
    sink_branch = df.sink(result_branch.append)
    result_main = []
    sink_main = df.sink(result_main.append)

    df.push(source=the_source,
            pipe=df.pipe(df.branch(slice, sink_branch), sink_main))

    if close_all:
        assert result_branch == the_source[:n_elements]
        assert result_main == the_source[:n_elements]
    else:
        assert result_branch == the_source[:n_elements]
        assert result_main == the_source
コード例 #3
0
ファイル: dataflow_test.py プロジェクト: jmalbos/dataflow
def test_slice_raises_ValueError(args):
    with raises(ValueError):
        df.slice(*args)