示例#1
0
def test_print_newline_start():
    console = Console(width=80, height=25)
    console.begin_capture()
    console.print("Foo", new_line_start=True)
    console.print("Foo\nbar\n", new_line_start=True)
    result = console.end_capture()

    assert result == "Foo\n\nFoo\nbar\n\n"
示例#2
0
def test_screen_update_class():
    screen_update = ScreenUpdate([[Segment("foo")], [Segment("bar")]], 5, 10)
    assert screen_update.x == 5
    assert screen_update.y == 10

    console = Console(force_terminal=True)
    console.begin_capture()
    console.print(screen_update)
    result = console.end_capture()
    print(repr(result))
    expected = "\x1b[11;6Hfoo\x1b[12;6Hbar"
    assert result == expected
示例#3
0
def test_update_screen():
    console = Console(force_terminal=True, width=20, height=5)
    if console.legacy_windows:
        return
    with pytest.raises(errors.NoAltScreen):
        console.update_screen("foo")
    console.begin_capture()
    with console.screen():
        console.update_screen("foo")
        console.update_screen("bar", region=Region(2, 3, 8, 4))
    result = console.end_capture()
    print(repr(result))
    expected = "\x1b[?1049h\x1b[H\x1b[?25l\x1b[1;1Hfoo                 \x1b[2;1H                    \x1b[3;1H                    \x1b[4;1H                    \x1b[5;1H                    \x1b[4;3Hbar     \x1b[5;3H        \x1b[6;3H        \x1b[7;3H        \x1b[?1049l\x1b[?25h"
    assert result == expected
示例#4
0
def test_out() -> None:
    console = Console(width=10)
    console.begin_capture()
    console.out(*(["foo bar"] * 5), sep=".", end="X")
    assert console.end_capture() == "foo bar.foo bar.foo bar.foo bar.foo barX"
示例#5
0
def test_bell() -> None:
    console = Console(force_terminal=True)
    console.begin_capture()
    console.bell()
    assert console.end_capture() == "\x07"