def test_custom_regex(capsys):
    regex = re.compile('^print this')
    string = ('print this...\n'
              'not this\n')

    assert spawn(['echo', '-n', string], 0,
                 output_regex=regex,
                 stripped_chars=' .\n') == 0
    out, err = capsys.readouterr()
    assert out == 'print this\n'
def test_custom_regex(capsys):
    regex = re.compile('^print this')
    string = ('print this...\n' 'not this\n')

    assert spawn(['echo', '-n', string],
                 0,
                 output_regex=regex,
                 stripped_chars=' .\n') == 0
    out, err = capsys.readouterr()
    assert out == 'print this\n'
Exemplo n.º 3
0
def run(conf, stack, verbosity=0, python=None):
    """Generate all needed files, run them and remove them again

    :conf: the launcher configuration to use
    :stack: the stack conf to use
    :verbosity: control the amount of output
    :python: the python executable to use locally
    """
    inventory = apply_template('inventory', python=python)
    playbook = generate(stack, conf)

    spawn(ansible_vars.GALAXY_INSTALL, verbosity)
    ansible_return = exec_playbook(inventory, playbook, verbosity)

    if ansible_return == 0:
        spawn(ansible_vars.GALAXY_REMOVE, verbosity)
        spawn(["rmdir", "roles"], 0)

    return ansible_return
Exemplo n.º 4
0
def run(conf, stack, verbosity=0, python=None):
    """Generate all needed files, run them and remove them again

    :conf: the launcher configuration to use
    :stack: the stack conf to use
    :verbosity: control the amount of output
    :python: the python executable to use locally
    """
    inventory = apply_template('inventory', python=python)
    playbook = generate(stack, conf)

    spawn(ansible_vars.GALAXY_INSTALL, verbosity)
    ansible_return = exec_playbook(inventory, playbook, verbosity)

    if ansible_return == 0:
        spawn(ansible_vars.GALAXY_REMOVE, verbosity)
        spawn(["rmdir", "roles"], 0)

    return ansible_return
def test_spawn_error(capsys):
    assert spawn(['false'], 0) == 1
    out, err = capsys.readouterr()
    assert out == ''
def test_spawn_stderr(capsys):
    assert spawn(['/bin/sh', '-c', 'echo -n something 1>&2'], 0) == 0
    out, err = capsys.readouterr()
    assert err == 'something'
def test_spawn_verbose(capsys):
    assert spawn(['echo', '-n', STRING], 1) == 0
    out, err = capsys.readouterr()
    assert out == STRING
def test_spawn_silent(capsys):
    assert spawn(['echo', '-n', STRING], 0) == 0
    out, err = capsys.readouterr()
    assert out == SHORT_STRING
def test_spawn_error(capsys):
    assert spawn(['false'], 0) == 1
    out, err = capsys.readouterr()
    assert out == ''
def test_spawn_stderr(capsys):
    assert spawn(['/bin/sh', '-c', 'echo -n something 1>&2'], 0) == 0
    out, err = capsys.readouterr()
    assert err == 'something'
def test_spawn_verbose(capsys):
    assert spawn(['echo', '-n', STRING], 1) == 0
    out, err = capsys.readouterr()
    assert out == STRING
def test_spawn_silent(capsys):
    assert spawn(['echo', '-n', STRING], 0) == 0
    out, err = capsys.readouterr()
    assert out == SHORT_STRING