Exemple #1
0
def test_bufview_readinto(buftype):
    buf = buftype(30)
    buf[:] = b"a" * 30
    r = io.BytesIO(b"b" * 20)
    view = compat.bufview(buf, 10, 10)
    r.readinto(view)
    assert buf[:] == b"a" * 10 + b"b" * 10 + b"a" * 10
Exemple #2
0
def test_bufview_write(buftype):
    buf = buftype(30)
    buf[:] = b"a" * 10 + b"b" * 10 + b"c" * 10
    view = compat.bufview(buf, 10, 10)
    w = io.BytesIO()
    w.write(view)
    assert w.getvalue() == b"b" * 10
Exemple #3
0
def test_bufview_readinto(buftype):
    buf = buftype(30)
    buf[:] = b"a" * 30
    r = io.BytesIO(b"b" * 20)
    view = compat.bufview(buf, 10, 10)
    r.readinto(view)
    assert buf[:] == b"a" * 10 + b"b" * 10 + b"a" * 10
Exemple #4
0
def test_bufview_write(buftype):
    buf = buftype(30)
    buf[:] = b"a" * 10 + b"b" * 10 + b"c" * 10
    view = compat.bufview(buf, 10, 10)
    w = io.BytesIO()
    w.write(view)
    assert w.getvalue() == b"b" * 10
Exemple #5
0
def test_bufview_readwrite(buftype):
    buf = buftype(30)
    buf[:] = b"a" * 30
    view = compat.bufview(buf, 10, 10)
    view[:] = b"b" * 10
    assert buf[:] == b"a" * 10 + b"b" * 10 + b"a" * 10
Exemple #6
0
def test_bufview_readonly(buftype):
    buf = buftype(30)
    buf[:] = b"a" * 10 + b"b" * 10 + b"c" * 10
    view = compat.bufview(buf, 10, 10)
    assert view[:] == b"b" * 10
Exemple #7
0
def test_bufview_readwrite(buftype):
    buf = buftype(30)
    buf[:] = b"a" * 30
    view = compat.bufview(buf, 10, 10)
    view[:] = b"b" * 10
    assert buf[:] == b"a" * 10 + b"b" * 10 + b"a" * 10
Exemple #8
0
def test_bufview_readonly(buftype):
    buf = buftype(30)
    buf[:] = b"a" * 10 + b"b" * 10 + b"c" * 10
    view = compat.bufview(buf, 10, 10)
    assert view[:] == b"b" * 10