Example #1
0
def test_iter_decompressed_zlib_can_read_all_bytes():
    """
    iter_decompressed_zlib will eventually read all of the bytes in the
    provided file object.
    """
    fobj = BytesIO(compressed_data)
    it = flash.iter_decompressed_zlib(fobj)
    assert list(it) == [b'\0'] * 65536 + list(iterbytes(decompressed_data))
Example #2
0
def test_iter_decompressed_zlib_can_read_all_bytes():
    """
    iter_decompressed_zlib will eventually read all of the bytes in the
    provided file object.
    """
    fobj = BytesIO(compressed_data)
    it = flash.iter_decompressed_zlib(fobj)
    assert list(it) == [b'\0'] * 65536 + list(iterbytes(decompressed_data))
Example #3
0
def test_iter_decompressed_zlib_reads_by_chunksize():
    """
    iter_decompressed_zlib will read from the provided file object in
    increments of chunksize.
    """
    fobj = BytesIO(compressed_data)
    it = flash.iter_decompressed_zlib(fobj, chunksize=99)
    next(it)
    assert fobj.tell() == 99
Example #4
0
def test_iter_decompressed_zlib_lazily_reads_chunks():
    """
    iter_decompressed_zlib reads chunks at a time; it will not read the entire
    file at once if it doesn't need to.
    """
    fobj = BytesIO(compressed_data)
    it = flash.iter_decompressed_zlib(fobj)
    next(it)
    assert fobj.tell() not in {0, len(compressed_data)}
Example #5
0
def test_iter_decompressed_zlib_reads_by_chunksize():
    """
    iter_decompressed_zlib will read from the provided file object in
    increments of chunksize.
    """
    fobj = BytesIO(compressed_data)
    it = flash.iter_decompressed_zlib(fobj, chunksize=99)
    next(it)
    assert fobj.tell() == 99
Example #6
0
def test_iter_decompressed_zlib_lazily_reads_chunks():
    """
    iter_decompressed_zlib reads chunks at a time; it will not read the entire
    file at once if it doesn't need to.
    """
    fobj = BytesIO(compressed_data)
    it = flash.iter_decompressed_zlib(fobj)
    next(it)
    assert fobj.tell() not in {0, len(compressed_data)}