Skip to content

Commit 72f4d4d

Browse files
committed
Add a test for /dev/stdin
1 parent 7060bf3 commit 72f4d4d

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

tests/test_xopen.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -690,3 +690,21 @@ def test_xopen_write_to_pipe(threads, ext):
690690
process.wait()
691691
process.stdout.close()
692692
assert data == CONTENT
693+
694+
695+
@pytest.mark.skipif(
696+
not os.path.exists("/dev/stdin"), reason="/dev/stdin does not exist"
697+
)
698+
@pytest.mark.parametrize("threads", (0, 1))
699+
def test_xopen_dev_stdin_read(threads, ext):
700+
if ext == ".zst" and zstandard is None:
701+
return
702+
file = str(Path(__file__).parent / f"file.txt{ext}")
703+
result = subprocess.run(
704+
f"cat {file} | python -c 'import xopen; "
705+
f'f=xopen.xopen("/dev/stdin", "rt", threads={threads});print(f.read())\'',
706+
shell=True,
707+
stdout=subprocess.PIPE,
708+
encoding="ascii",
709+
)
710+
assert result.stdout == CONTENT + "\n"

0 commit comments

Comments
 (0)