Beispiel #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"
Beispiel #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")