def test_stream_decompress(): data = 'abc\ndef\n123'.encode() assert [s.strip() for s in stream_decompress('', data)] == \ ['abc', 'def', '123'] assert [s.strip() for s in stream_decompress('bz2', bz2.compress(data))] == \ ['abc', 'def', '123'] with tmpfile() as fn: f = gzip.open(fn, 'wb') f.write(data) f.close() with open(fn, 'rb') as f: compressed = f.read() assert [s.strip() for s in stream_decompress('gz', compressed)] == \ [b'abc', b'def', b'123']