示例#1
0
def test_simple_reading(ch: channel.Channel) -> None:
    ch.write(b"1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ")
    out = ch.read(10)
    assert out == b"1234567890"

    out = ch.read()
    assert out == b"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
示例#2
0
def test_simple_read_iter(ch: channel.Channel) -> None:
    ch.write(b"12345678901234567890")
    final = bytearray()
    for new in ch.read_iter(10):
        final.extend(new)
    assert final == b"1234567890"
    for i in range(1, 10):
        c = ch.read(1)
        assert c == str(i).encode("utf-8")
示例#3
0
def test_simple_command(ch: channel.Channel) -> None:
    ch.sendline("echo Hello World", read_back=True)
    out = ch.read()
    assert out.startswith(b"Hello World")