1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
|
import pytest
def test_1(ctx):
buf = ctx.buffer(b'abc')
with pytest.raises(Exception):
buf.write(b'1234')
with pytest.raises(Exception):
buf.write(b'u', offset=-1)
with pytest.raises(Exception):
buf.write(b'abc', offset=1)
def test_2(ctx):
buf = ctx.buffer(b'123456789')
with pytest.raises(Exception):
buf.write_chunks(b'12345', 0, 1, 4)
with pytest.raises(Exception):
buf.write_chunks(b'12345', 0, 1, 6)
with pytest.raises(Exception):
buf.write_chunks(b'yyyyyn', 4, 1, 6)
with pytest.raises(Exception):
buf.write_chunks(b'yyyyyn', 4, -1, 6)
with pytest.raises(Exception):
buf.write_chunks(b'yn', -1, 2, 1)
def test_3(ctx):
buf = ctx.buffer(b'123456789')
with pytest.raises(Exception):
buf.write_chunks(b'yyyyyn', 2, 3, 3)
with pytest.raises(Exception):
buf.write_chunks(b'ynyyyy', -1, -3, 3)
with pytest.raises(Exception):
buf.write_chunks(b'yyyyny', -4, -3, 3)
def test_4(ctx):
buf = ctx.buffer(b'123456789')
with pytest.raises(Exception):
buf.write_chunks(b'yyynyy', 0, 2, 2)
|