Skip to content

Commit c921926

Browse files
committed
Add test for the RecompressorStream
1 parent 8bff77d commit c921926

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

test/test_recompressor.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,3 +101,14 @@ def test_recompressor_stream(tmp_path):
101101
output.write(chunk)
102102
assert stream.processed_records == 3
103103
assert os.path.getsize(tmp_file) > 0
104+
105+
def test_recompressor_stream_on_uncompressed_warc(tmp_path):
106+
"""Uncompress a badly chunked stream with gzip befor feeding it to a RecompressorStream and write it to a file."""
107+
test_file = get_test_file('example-bad-non-chunked.warc.gz')
108+
tmp_file = tmp_path / "output.warc.gz"
109+
with gzip.open(test_file, "rb") as input, open(tmp_file, "wb") as output:
110+
stream = RecompressorStream(input, verbose=True)
111+
while chunk := stream.read():
112+
output.write(chunk)
113+
assert stream.processed_records == 6
114+
assert os.path.getsize(tmp_file) > 0

0 commit comments

Comments
 (0)