def test_error_codes(test): """Tests error codes.""" sh.sh("-c", sh.true(), _shell=True).execute().status() == 0 assert pytest.raises(psh.ExecutionError, lambda: sh.sh("-c", sh.false(), _shell=True).execute()).value.status() == 1 pipe = sh.cat() | sh.egrep("bbb|ccc") | sh.grep("ccc") assert pytest.raises(psh.ExecutionError, lambda: sh.sh("-c", pipe, _stdin="aaa\n", _shell=True).execute()).value.status() == 128 assert pytest.raises(psh.ExecutionError, lambda: sh.sh("-c", pipe, _stdin="bbb\n", _shell=True).execute()).value.status() == 1
def test_error_codes(test): """Tests error codes.""" sh.sh("-c", sh.true(), _shell=True).execute().status() == 0 assert pytest.raises( psh.ExecutionError, lambda: sh.sh("-c", sh.false(), _shell=True). execute()).value.status() == 1 pipe = sh.cat() | sh.egrep("bbb|ccc") | sh.grep("ccc") assert pytest.raises( psh.ExecutionError, lambda: sh.sh("-c", pipe, _stdin="aaa\n", _shell=True).execute( )).value.status() == 128 assert pytest.raises( psh.ExecutionError, lambda: sh.sh("-c", pipe, _stdin="bbb\n", _shell=True).execute( )).value.status() == 1
def test_execution(test): """Tests command execution in the shell mode.""" process = sh.sh("-c", sh.echo("aaa", _stdout=STDERR), _shell=True).execute() assert process.stdout() == "" assert process.stderr() == "aaa\n" process = sh.sh( c=sh.sh("-c", "echo aaa >&2", _stderr=STDOUT), _shell=True).execute() assert process.stdout() == "aaa\n" assert process.stderr() == "" process = sh.sh("-c", sh.echo("aaa", _stdout=DEVNULL), _shell=True).execute() assert process.stdout() == "" assert process.stderr() == "" pipe = sh.cat() | sh.egrep("bbb|ccc") | sh.grep("ccc") process = sh.sh("-c", pipe, _stdin="aaa\nbbb\nccc\n", _shell=True).execute() assert process.stdout() == "ccc\n" assert process.stderr() == ""
def test_execution(test): """Tests command execution in the shell mode.""" process = sh.sh("-c", sh.echo("aaa", _stdout=STDERR), _shell=True).execute() assert process.stdout() == "" assert process.stderr() == "aaa\n" process = sh.sh(c=sh.sh("-c", "echo aaa >&2", _stderr=STDOUT), _shell=True).execute() assert process.stdout() == "aaa\n" assert process.stderr() == "" process = sh.sh("-c", sh.echo("aaa", _stdout=DEVNULL), _shell=True).execute() assert process.stdout() == "" assert process.stderr() == "" pipe = sh.cat() | sh.egrep("bbb|ccc") | sh.grep("ccc") process = sh.sh("-c", pipe, _stdin="aaa\nbbb\nccc\n", _shell=True).execute() assert process.stdout() == "ccc\n" assert process.stderr() == ""