def test_multi_captured(capfd): stream = StringIO() with redirect_stdout(stream): m.captured_output("a") m.raw_output("b") m.captured_output("c") m.raw_output("d") stdout, stderr = capfd.readouterr() assert stdout == 'bd' assert stream.getvalue() == 'ac'
def test_multi_captured(capfd): stream = StringIO() with redirect_stdout(stream): m.captured_output("a") m.raw_output("b") m.captured_output("c") m.raw_output("d") stdout, stderr = capfd.readouterr() assert stdout == "bd" assert stream.getvalue() == "ac"
def test_captured(capsys): msg = "I've been redirected to Python, I hope!" m.captured_output(msg) stdout, stderr = capsys.readouterr() assert stdout == msg assert stderr == "" m.captured_output_default(msg) stdout, stderr = capsys.readouterr() assert stdout == msg assert stderr == "" m.captured_err(msg) stdout, stderr = capsys.readouterr() assert stdout == "" assert stderr == msg
def test_captured(capsys): msg = "I've been redirected to Python, I hope!" m.captured_output(msg) stdout, stderr = capsys.readouterr() assert stdout == msg assert stderr == '' m.captured_output_default(msg) stdout, stderr = capsys.readouterr() assert stdout == msg assert stderr == '' m.captured_err(msg) stdout, stderr = capsys.readouterr() assert stdout == '' assert stderr == msg
def test_not_captured(capfd): msg = "Something that should not show up in log" stream = StringIO() with redirect_stdout(stream): m.raw_output(msg) stdout, stderr = capfd.readouterr() assert stdout == msg assert stderr == "" assert stream.getvalue() == "" stream = StringIO() with redirect_stdout(stream): m.captured_output(msg) stdout, stderr = capfd.readouterr() assert stdout == "" assert stderr == "" assert stream.getvalue() == msg
def test_not_captured(capfd): msg = "Something that should not show up in log" stream = StringIO() with redirect_stdout(stream): m.raw_output(msg) stdout, stderr = capfd.readouterr() assert stdout == msg assert stderr == '' assert stream.getvalue() == '' stream = StringIO() with redirect_stdout(stream): m.captured_output(msg) stdout, stderr = capfd.readouterr() assert stdout == '' assert stderr == '' assert stream.getvalue() == msg
def test_series_captured(capture): with capture: m.captured_output("a") m.captured_output("b") assert capture == "ab"