def test_pipes(): result = (sh('tests/cli.tool -o "hello"') | sh('tests/cli.tool -i')).run() assert result == ShellCommandResult(stdout='STDIN: STDOUT: hello\n\n')
def test_raise_for_status_success(): assert sh('tests/cli.tool').raise_for_status() == ShellCommandResult()
def test_stdin_file(): result = (sh % 'tests/cli.tool -i' < 'tests/test_input.txt').run() # One newline belongs to the test file, the other is a standard part of # cli.tool's output. assert result == ShellCommandResult(stdout='STDIN: Test input file.\n\n')
def test_stdin_writing(): result = (sh % 'tests/cli.tool -i' << 'hi stdin').run() assert result == ShellCommandResult(stdout='STDIN: hi stdin\n')
def test_stderr_capture(): result = (sh % 'tests/cli.tool -e "hi there"').run() assert result == ShellCommandResult(stderr='STDERR: hi there\n')
def test_stdout_capture(): result = (sh % 'tests/cli.tool -o "hi there"').run() assert result == ShellCommandResult(stdout='STDOUT: hi there\n')
def test_exit_code(): result = (sh % 'tests/cli.tool -x 42').run() assert result == ShellCommandResult(exit_code=42)
def test_can_run(): result = (sh % 'tests/cli.tool').run() assert result == ShellCommandResult()