コード例 #1
0
def test_seek_to_tell():
    fileobj = StringIO('this is a cool test')
    stream = LimitingStream(fileobj, 3)
    stream.seek(stream.tell())

    assert stream.read(4) == 'thi'
    assert 3 == stream.tell()
コード例 #2
0
def test_seek_withlimit():
    fileobj = StringIO('this is a cool test')
    stream = LimitingStream(fileobj, 3)
    stream.seek(2)

    assert stream.read(2) == 'i'
    assert 3 == stream.tell()
コード例 #3
0
def test_seek_pastlimit():
    fileobj = StringIO('this is a cool test')
    stream = LimitingStream(fileobj, 3)
    stream.seek(4)

    assert stream.read(1) == ''
    assert 3 == stream.tell()
コード例 #4
0
def test_seek():
    fileobj = StringIO('this is a cool test')
    stream = LimitingStream(fileobj)
    stream.seek(2)

    assert stream.read(2) == 'is'
    assert 4 == stream.tell()
コード例 #5
0
ファイル: test_filelike.py プロジェクト: epasham/quay-1
def test_seek_to_tell():
    fileobj = BytesIO(b"this is a cool test")
    stream = LimitingStream(fileobj, 3)
    stream.seek(stream.tell())

    assert stream.read(4) == b"thi"
    assert 3 == stream.tell()
コード例 #6
0
ファイル: test_filelike.py プロジェクト: epasham/quay-1
def test_seek_pastlimit():
    fileobj = BytesIO(b"this is a cool test")
    stream = LimitingStream(fileobj, 3)
    stream.seek(4)

    assert stream.read(1) == b""
    assert 3 == stream.tell()
コード例 #7
0
ファイル: test_filelike.py プロジェクト: epasham/quay-1
def test_seek_withlimit():
    fileobj = BytesIO(b"this is a cool test")
    stream = LimitingStream(fileobj, 3)
    stream.seek(2)

    assert stream.read(2) == b"i"
    assert 3 == stream.tell()
コード例 #8
0
ファイル: test_filelike.py プロジェクト: epasham/quay-1
def test_seek():
    fileobj = BytesIO(b"this is a cool test")
    stream = LimitingStream(fileobj)
    stream.seek(2)

    assert stream.read(2) == b"is"
    assert 4 == stream.tell()