Exemplo n.º 1
0
def test_run_command_streams_stderr_on_failure(capsys):
    commands = [
        'python',
        '-c',
        'import sys; sys.exit("stderr")',
    ]
    cmd = util.get_run_command(commands)
    util.run_command(cmd, stream=True)

    captured = capsys.readouterr()
    assert 'stderr\n' == captured.out
Exemplo n.º 2
0
def test_run_command_raises_and_prints_stderr_on_failure(_patched_red_text):
    commands = [
        'python',
        '-c',
        'import sys; sys.exit("stderr")',
    ]
    with pytest.raises(SystemExit) as e:
        cmd = util.get_run_command(commands)
        util.run_command(cmd)

    assert 1 == e.value.code
    msg = 'ERROR: Command failed to execute\n\nstderr\n'
    _patched_red_text.assert_called_once_with(msg)
Exemplo n.º 3
0
def test_run_command_streams_stdout(capsys):
    cmd = util.get_run_command(['echo', 'stdout'])
    util.run_command(cmd, stream=True)

    captured = capsys.readouterr()
    assert 'stdout\n' == captured.out
Exemplo n.º 4
0
def test_run_command():
    cmd = util.get_run_command(['echo', 'foo'])
    x = (0, 'foo\n')

    assert x == util.run_command(cmd)