Skip to content

Commit 341969d

Browse files
committed
Good test for bytesio
1 parent 840e53f commit 341969d

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

tests/test_xopen.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -591,17 +591,20 @@ def test_pass_file_object_for_writing(tmp_path, ext):
591591
assert fh.readline() == first_line
592592

593593

594-
@pytest.mark.parametrize("ext", extensions)
595-
def test_pass_bytesio_for_writing(ext):
594+
@pytest.mark.parametrize(["threads", "ext"], itertools.product((0, 1), extensions))
595+
def test_pass_bytesio_for_reading_and_writing(ext, threads):
596596
filelike = io.BytesIO()
597597
format = ext[1:]
598598
if ext == "":
599599
format = None
600600
if ext == ".zst" and zstandard is None:
601601
return
602602
first_line = CONTENT_LINES[0].encode("utf-8")
603-
with xopen(filelike, "wb", format=format) as f:
604-
f.write(first_line)
603+
writer = xopen(filelike, "wb", format=format, threads=threads)
604+
writer.write(first_line)
605+
if writer is not filelike:
606+
writer.close()
607+
assert not filelike.closed
605608
filelike.seek(0)
606-
with xopen(filelike, "rb", format=format) as fh:
609+
with xopen(filelike, "rb", format=format, threads=threads) as fh:
607610
assert fh.readline() == first_line

0 commit comments

Comments
 (0)