def test_none_read(): class NoneReader(object): def read(self, size=None): return None stream = StreamSlice(NoneReader(), 0) assert stream.read(-1) == None assert stream.tell() == 0
def test_slice_explictread(): fileobj = StringIO('this is a cool test') stream = StreamSlice(fileobj, 5, 9) assert stream.read(2) == 'is' assert stream.read(5) == ' a' assert len('is a') == stream.tell()
def test_startindex_limitedread(): fileobj = StringIO('this is a cool test') stream = StreamSlice(fileobj, 5) assert stream.read(4) == 'is a' assert 4 == stream.tell()
def test_startindex(): fileobj = StringIO('this is a cool test') stream = StreamSlice(fileobj, 5) assert stream.read(-1) == 'is a cool test' assert len('is a cool test') == stream.tell()
def test_noslice(): fileobj = StringIO('this is a cool test') stream = StreamSlice(fileobj, 0) assert stream.read(-1) == 'this is a cool test' assert len('this is a cool test') == stream.tell()
def test_startindex_limitedread(): fileobj = BytesIO(b"this is a cool test") stream = StreamSlice(fileobj, 5) assert stream.read(4) == b"is a" assert 4 == stream.tell()
def test_slice_explictread(): fileobj = BytesIO(b"this is a cool test") stream = StreamSlice(fileobj, 5, 9) assert stream.read(2) == b"is" assert stream.read(5) == b" a" assert len(b"is a") == stream.tell()
def test_startindex(): fileobj = BytesIO(b"this is a cool test") stream = StreamSlice(fileobj, 5) assert stream.read(-1) == b"is a cool test" assert len(b"is a cool test") == stream.tell()
def test_noslice(): fileobj = BytesIO(b"this is a cool test") stream = StreamSlice(fileobj, 0) assert stream.read(-1) == b"this is a cool test" assert len(b"this is a cool test") == stream.tell()
def test_slice_explictread(): fileobj = StringIO("this is a cool test") stream = StreamSlice(fileobj, 5, 9) assert stream.read(2) == "is" assert stream.read(5) == " a" assert len("is a") == stream.tell()
def test_startindex(): fileobj = StringIO("this is a cool test") stream = StreamSlice(fileobj, 5) assert stream.read(-1) == "is a cool test" assert len("is a cool test") == stream.tell()
def test_noslice(): fileobj = StringIO("this is a cool test") stream = StreamSlice(fileobj, 0) assert stream.read(-1) == "this is a cool test" assert len("this is a cool test") == stream.tell()