コード例 #1
0
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
コード例 #2
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()
コード例 #3
0
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()
コード例 #4
0
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()
コード例 #5
0
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()
コード例 #6
0
ファイル: test_filelike.py プロジェクト: epasham/quay-1
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()
コード例 #7
0
ファイル: test_filelike.py プロジェクト: epasham/quay-1
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()
コード例 #8
0
ファイル: test_filelike.py プロジェクト: epasham/quay-1
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()
コード例 #9
0
ファイル: test_filelike.py プロジェクト: epasham/quay-1
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()
コード例 #10
0
ファイル: test_filelike.py プロジェクト: zhill/quay
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()
コード例 #11
0
ファイル: test_filelike.py プロジェクト: zhill/quay
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()
コード例 #12
0
ファイル: test_filelike.py プロジェクト: zhill/quay
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()