From 58fe3fdb33a49ff4f02f2fd545114a7bca9c612e Mon Sep 17 00:00:00 2001 From: Marcel Martin Date: Thu, 15 May 2025 13:01:14 +0200 Subject: [PATCH] Test reading concatenated/multiblock gzips works --- tests/test_xopen.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tests/test_xopen.py b/tests/test_xopen.py index 86234bc..9e8f816 100644 --- a/tests/test_xopen.py +++ b/tests/test_xopen.py @@ -345,6 +345,20 @@ def test_bare_read_from_gz(): assert f.read() == "hello" +@pytest.mark.parametrize("threads", [None, 0, 2]) +def test_concatenated_gzip(tmp_path, threads): + path = tmp_path / "hello.gz" + with gzip.open(path, mode="wt") as f: + print("Hello", file=f) + with gzip.open(path, mode="at") as f: + print("world", file=f) + + with xopen(path, threads=threads) as f: + lines = list(f) + + assert lines == ["Hello\n", "world\n"] + + def test_read_no_threads(ext): klasses = { ".bz2": bz2.BZ2File,