예제 #1
0
def test_dynamicprint_init():
    printer = br.DynamicPrint()
    assert printer._last_print == ""
    assert printer._next_print == ""
    assert printer.out_type == sys.stdout
    assert not printer.quiet

    printer = br.DynamicPrint(out_type="stderr")
    assert printer.out_type == sys.stderr
예제 #2
0
def test_dynamicprint_write(capsys):
    printer = br.DynamicPrint()
    printer.write("Hello")
    printer.new_line(2)
    printer.write("foo")
    printer.clear()
    printer.write("bar")
    out, err = capsys.readouterr()
    assert out == "\r\rHello\n\n\r\rfoo\r   \r\r\rbar"
    assert err == ""

    printer = br.DynamicPrint(out_type="stderr")
    printer.write("Hello")
    out, err = capsys.readouterr()
    assert out == ""
    assert err == "\r\rHello"

    printer = br.DynamicPrint(quiet=True)
    printer.write("Hello")
    out, err = capsys.readouterr()
    assert out == ""
    assert err == ""