示例#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
示例#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
示例#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
示例#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
示例#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
示例#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
示例#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
示例#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