def test_echo(): test_str = "hello world" x = command_format("echo {}", test_str) p = run_local(x, capture_output=True, text=True) assert p.stdout.strip() == test_str
def test_fmt(): x = command_format(''' command1 command2 command3 ''') y = CmdList(['command1', 'command2', 'command3']) assert x == y
def test_fmt_line_joining(): x = command_format(''' command1 command2 command3 \\ arg1 ''') y = CmdList(['command1', 'command2', 'command3 arg1']) assert x == y
def test_arg1(): x = command_format("command {}", "rm -rf /") x = str(x) x = shlex.split(x) assert x[0] == "/bin/bash" assert x[1] == "-c" y = shlex.split(x[2]) assert y[0] == "command" assert y[1] == "rm -rf /"
def test_check(): x = command_format("false") with pytest.raises(subprocess.CalledProcessError): run_local(x, check=True)
def test_false(): x = command_format("false") p = run_local(x) assert p.returncode == 1
def test_check(): x = command_format("false") with pytest.raises(RemoteCalledProcessError): run_remote(HOSTNAME, x, check=True)
def test_false(): x = command_format("false") p = run_remote(HOSTNAME, x) assert p.returncode == 1