def test_simple_string_command(): sh('ls -lrt')
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_raise_for_status_failure(): with pytest.raises(CalledProcessError): sh('tests/cli.tool -x 42').raise_for_status()
def test_simplified_stderr(): assert sh('tests/cli.tool -e "errput"').stderr == b'STDERR: errput\n'
def test_simplified_exit_code(): assert sh('tests/cli.tool -x 42').exit_code == 42
def test_simplified_stdout(): assert sh('tests/cli.tool -o "output"').stdout == b'STDOUT: output\n'
def test_item_access_helper(): sh['tests/cli.tool']('-o', 'hi') == sh('tests/cli.tool -o hi')
def test_attribute_access_helper(): sh.ls('-lrt') == sh('ls -lrt')
def test_bad_type_command(): with pytest.raises(TypeError): sh(1)
def test_list_command(): sh(['ls', '-lrt'])