Exemplo n.º 1
0
def test_capture_cmd_capture_success():
    # This should succeed
    for line in utils.execute_cmd(["/bin/bash", "-c", "echo test"], capture=True):
        assert line == "test\n"
Exemplo n.º 2
0
def test_capture_cmd_capture_fail():
    with pytest.raises(subprocess.CalledProcessError):
        for line in utils.execute_cmd(
            ["/bin/bash", "-c", "echo test; exit 1 "], capture=True
        ):
            assert line == "test\n"
Exemplo n.º 3
0
def test_capture_cmd_no_capture_success():
    # This should succeed
    for line in utils.execute_cmd(["/bin/bash", "-c", "echo test"]):
        pass
Exemplo n.º 4
0
def test_capture_cmd_no_capture_fail():
    with pytest.raises(subprocess.CalledProcessError):
        for line in utils.execute_cmd(["/bin/bash", "-c", "e "]):
            pass
Exemplo n.º 5
0
def test_capture_cmd_noeol_capture_success():
    # This should succeed
    lines = list(
        utils.execute_cmd(["/bin/bash", "-c", "echo -en 'test\ntest'"],
                          capture=True))
    assert lines == ["test\n", "test"]
Exemplo n.º 6
0
def test_capture_cmd_capture_fail():
    with pytest.raises(subprocess.CalledProcessError):
        for line in utils.execute_cmd([
            '/bin/bash', '-c', 'echo test; exit 1 '
        ], capture=True):
            assert line == 'test\n'
Exemplo n.º 7
0
def test_capture_cmd_capture_success():
    # This should succeed
    for line in utils.execute_cmd([
        '/bin/bash', '-c', 'echo test'
    ], capture=True):
        assert line == 'test\n'
Exemplo n.º 8
0
def test_capture_cmd_no_capture_fail():
    with pytest.raises(subprocess.CalledProcessError):
        for line in utils.execute_cmd([
            '/bin/bash', '-c', 'e '
        ]):
            pass
Exemplo n.º 9
0
def test_capture_cmd_no_capture_success():
    # This should succeed
    for line in utils.execute_cmd([
        '/bin/bash', '-c', 'echo test'
    ]):
        pass