예제 #1
0
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
예제 #2
0
def test_fmt():
    x = command_format('''
        command1
        command2
        command3
        ''')
    y = CmdList(['command1', 'command2', 'command3'])

    assert x == y
예제 #3
0
def test_fmt_line_joining():
    x = command_format('''
        command1
        command2
        command3 \\
            arg1
        ''')
    y = CmdList(['command1', 'command2', 'command3 arg1'])

    assert x == y
예제 #4
0
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 /"
예제 #5
0
def test_check():
    x = command_format("false")

    with pytest.raises(subprocess.CalledProcessError):
        run_local(x, check=True)
예제 #6
0
def test_false():
    x = command_format("false")
    p = run_local(x)

    assert p.returncode == 1
예제 #7
0
def test_check():
    x = command_format("false")

    with pytest.raises(RemoteCalledProcessError):
        run_remote(HOSTNAME, x, check=True)
예제 #8
0
def test_false():
    x = command_format("false")
    p = run_remote(HOSTNAME, x)

    assert p.returncode == 1