Skip to content

Commit 1717d09

Browse files
committed
Also test threads for reading and writing filelike objects
1 parent b24c396 commit 1717d09

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

tests/test_xopen.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -569,25 +569,25 @@ def test_xopen_zst_fails_when_zstandard_not_available(monkeypatch):
569569
f.read()
570570

571571

572-
@pytest.mark.parametrize("ext", extensions)
573-
def test_pass_file_object_for_reading_no_threads(ext):
572+
@pytest.mark.parametrize(["threads", "ext"], itertools.product((0, 1), extensions))
573+
def test_pass_file_object_for_reading(ext, threads):
574574
if ext == ".zst" and zstandard is None:
575575
return
576576

577577
with open(TEST_DIR / f"file.txt{ext}", "rb") as fh:
578-
with xopen(fh, mode="rb", threads=0) as f:
578+
with xopen(fh, mode="rb", threads=threads) as f:
579579
assert f.readline() == CONTENT_LINES[0].encode("utf-8")
580580

581581

582-
@pytest.mark.parametrize("ext", extensions)
583-
def test_pass_file_object_for_writing(tmp_path, ext):
582+
@pytest.mark.parametrize(["threads", "ext"], itertools.product((0, 1), extensions))
583+
def test_pass_file_object_for_writing(tmp_path, ext, threads):
584584
if ext == ".zst" and zstandard is None:
585585
return
586586
first_line = CONTENT_LINES[0].encode("utf-8")
587587
with open(tmp_path / "out{ext}", "wb") as fh:
588-
with xopen(fh, "wb") as f:
588+
with xopen(fh, "wb", threads=threads) as f:
589589
f.write(first_line)
590-
with xopen(tmp_path / "out{ext}", "rb") as fh:
590+
with xopen(tmp_path / "out{ext}", "rb", threads=threads) as fh:
591591
assert fh.readline() == first_line
592592

593593

0 commit comments

Comments
 (0)