Exemplo n.º 1
0
def test_pipe_dup_save_text_tty():
    print_testname(test_pipe_dup_save_text_tty.__name__)

    print_runtime_flag()
    print_msg("* Should be in color.")
    print_msg("* Should contain title and status.")
    print_msg("* Should contain stdout and stderr messages.")
    print_msg("* Should contain stdout and stderr of subprocess as well.")

    p = Pipe(dup=True, save=True, tty=True, text=True)

    cr = cmd_print_stdout_stderr(return_val='foo',
                                 with_sub=True,
                                 _stdout=p,
                                 _stderr=p)

    print_result_flag('out')
    print_msg("* Should contain all stdout lines in color.")
    print_msg("* Should contain stdout and stderr of subprocess as well.")
    print(cr.stdout)

    print_result_flag('err')
    print_msg("* Should contain all stderr lines in color.")
    print_msg("* Should contain stdout and stderr of subprocess as well.")
    print(cr.stderr)
Exemplo n.º 2
0
def test_pickle():
    print_testname(test_pickle.__name__)
    print_runtime_flag()
    print_msg("* Should be in color.")
    print_msg("* Should contain title and status.")
    print_msg("* Should contain stdout and stderr messages.")
    print_msg("* Should contain stdout and stderr of subprocess as well.")

    p = Pipe(dup=True, save=True, tty=True, text=True, mute=False)

    with Executor() as excecutor:
        future = excecutor.submit(cmd_print_stdout_stderr,
                                  'foo',
                                  with_sub=True,
                                  _stdout=p,
                                  _stderr=p)
        cr = future.result()

    print_result_flag('out')
    print_msg("* Should contain all stdout lines in color.")
    print_msg("* Should contain stdout and stderr of subprocess as well.")
    print(cr.stdout)

    print_result_flag('err')
    print_msg("* Should contain all stderr lines in color.")
    print_msg("* Should contain stdout and stderr of subprocess as well.")
    print(cr.stderr)
Exemplo n.º 3
0
def test_dup_subprocess_output_exists():

    p = Pipe(dup=True, save=True, mute=False, text=True, tty=False)

    cr = cmd_print_stdout_stderr(with_sub=True, _stdout=p, _stderr=p)

    assert "stdout_text\n" in cr.stdout
    assert "subprocess: stdout_text 1\n" in cr.stdout
    assert "subprocess: stderr_text" in cr.stderr
Exemplo n.º 4
0
def test_redirect_stderr_to_stdout():

    p = Pipe(dup=True, save=True, mute=False, text=True, tty=True)

    cr = cmd_print_stdout_stderr(with_sub=True, _stdout=p, _stderr=STDOUT)

    assert cr.stderr is None
    assert f'{fg.magenta}stdout_ansi_text{fg.rs}\n' in cr.stdout
    assert f'{fg.magenta}stderr_ansi_text{fg.rs}\n' in cr.stdout
Exemplo n.º 5
0
def test_tty_true(capfd):

    p = Pipe(dup=False, save=True, mute=False, text=True, tty=True)

    cr = cmd_print_stdout_stderr(with_sub=False, _stdout=p, _stderr=p)

    stdout, stderr = capfd.readouterr()

    assert f'{fg.magenta}stdout_ansi_text{fg.rs}\n' in stdout
    assert f'{fg.magenta}stderr_ansi_text{fg.rs}\n' in stderr
    assert f'{fg.magenta}stdout_ansi_text{fg.rs}\n' in cr.stdout
    assert f'{fg.magenta}stderr_ansi_text{fg.rs}\n' in cr.stderr