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
|
import pytest
def test_1(ctx):
buf = ctx.buffer(b'abc')
with pytest.raises(Exception):
buf.read(4)
with pytest.raises(Exception):
buf.read(offset=-1)
with pytest.raises(Exception):
buf.read(offset=1, size=3)
def test_2(ctx):
buf = ctx.buffer(b'123456789')
with pytest.raises(Exception):
buf.read_chunks(1, 4, 1, 6)
with pytest.raises(Exception):
buf.read_chunks(1, 4, -1, 6)
with pytest.raises(Exception):
buf.read_chunks(2, -1, 2, 1)
def test_3(ctx):
buf = ctx.buffer(b'123456789')
with pytest.raises(Exception):
buf.read_chunks(2, 2, 3, 3)
with pytest.raises(Exception):
buf.read_chunks(2, -1, -3, 3)
with pytest.raises(Exception):
buf.read_chunks(2, -4, -3, 3)
def test_4(ctx):
buf = ctx.buffer(b'123456789')
with pytest.raises(Exception):
buf.read_chunks(3, 0, 2, 2)
|