Skip to content

Commit

Permalink
Add a test for /dev/stdin
Browse files Browse the repository at this point in the history
  • Loading branch information
rhpvorderman committed Mar 28, 2024
1 parent 7060bf3 commit 981bea4
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions tests/test_xopen.py
Original file line number Diff line number Diff line change
Expand Up @@ -690,3 +690,21 @@ def test_xopen_write_to_pipe(threads, ext):
process.wait()
process.stdout.close()
assert data == CONTENT


@pytest.mark.skipif(
not os.path.exists("/dev/stdin"), reason="/dev/stdin does not exist"
)
@pytest.mark.parametrize("threads", (0, 1))
def test_xopen_dev_stdin_read(threads, ext):
if ext == ".zst" and zstandard is None:
return
file = str(Path(__file__).parent / f"file.txt{ext}")
result = subprocess.run(
f"cat {file} | python -c 'import xopen; "
f'f=xopen.xopen("/dev/stdin", "rt");print(f.read())\'',
shell=True,
stdout=subprocess.PIPE,
encoding="ascii",
)
assert result.stdout == CONTENT + "\n"

0 comments on commit 981bea4

Please sign in to comment.