Exemplo n.º 1
0
def test_positive_stderr(capsys):
    """Testing that if string starts with error output in stderr"""
    my_precious_logger("error - this should be in stderr")
    captured = capsys.readouterr()
    assert captured.err == "error - this should be in stderr"
def test_positive_case1(capsys):
    """Example 1 from the task"""
    my_precious_logger("error: file not found")
    captured = capsys.readouterr()
    assert captured.err == "error: file not found"
Exemplo n.º 3
0
def test_positive_stdout(capsys):
    """Testing that if string starts not with error output in stdout (or print)"""
    my_precious_logger("everything's OK")
    captured = capsys.readouterr()
    assert captured.out == "everything's OK"
def test_positive_case4(capsys):
    my_precious_logger("error - captured in stderr")
    captured = capsys.readouterr()
    assert captured.err == "error - captured in stderr"
def test_positive_case3(capsys):
    my_precious_logger("NOT an error - captured in stdout")
    captured = capsys.readouterr()
    assert captured.out == "NOT an error - captured in stdout"
def test_positive_case2(capsys):
    """Example 2 from the task"""
    my_precious_logger("OK")
    captured = capsys.readouterr()
    assert captured.out == "OK"
def test_my_precious_logger_stdout(capfd):
    """Test my precious logger if text not for an errorlog"""
    text = "text doesn't startswith error"
    my_precious_logger(text)
    out, err = capfd.readouterr()
    assert out == text + "\n"  # print() add \n
def test_my_precious_logger_stderr(capfd):
    """Test my precious logger if text for an errorlog"""
    text = "error: this text has error!!!! Alarm "
    my_precious_logger(text)
    out, err = capfd.readouterr()
    assert err == text + "\n"  # print() add \n