def test_piping():
    cmd_ls = clom.ls.with_opts('-lah')
    cmd_ls._env = {}
    cmd_echo = clom.echo.with_opts("monkey", "gorilla")
    cmd_grep = clom.grep.with_opts('monkey')

    ls_pipe_echo = cmd_ls.pipe_to(cmd_echo)
    ls_pipe_echo_expected = 'ls -lah | echo monkey gorilla' 
    assert ls_pipe_echo_expected == str(ls_pipe_echo)

    ls_pipe_echo = cmd_ls | cmd_echo
    assert ls_pipe_echo_expected == str(ls_pipe_echo)

    ls_pipe_echo_pipe_grep = ls_pipe_echo.pipe_to(cmd_grep)
    ls_pipe_echo_pipe_grep_expected = ls_pipe_echo_expected + ' | grep monkey'
    assert ls_pipe_echo_pipe_grep_expected == str(ls_pipe_echo_pipe_grep)

    ls_pipe_echo_pipe_grep = ls_pipe_echo | cmd_grep
    assert ls_pipe_echo_pipe_grep_expected == str(ls_pipe_echo_pipe_grep)
Verify that piping several commands together behaves as expected.
dataset/ETHPy150Open six8/python-clom/src/tests/test_clom.py/test_piping