diff options
author | David Robillard <d@drobilla.net> | 2021-01-09 19:17:31 +0100 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2021-03-07 15:32:23 -0500 |
commit | b9d0b9f058807d7253e88d37822c47b5462b65ea (patch) | |
tree | 680357643905465c27857a1f3709ce3518ad7f82 /test/test_stdin.py | |
parent | 4c663def32cb6c360ab3d9e2f101c903583d1486 (diff) | |
download | serd-b9d0b9f058807d7253e88d37822c47b5462b65ea.tar.gz serd-b9d0b9f058807d7253e88d37822c47b5462b65ea.tar.bz2 serd-b9d0b9f058807d7253e88d37822c47b5462b65ea.zip |
WIP: Switch to Meson
Diffstat (limited to 'test/test_stdin.py')
-rwxr-xr-x | test/test_stdin.py | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/test/test_stdin.py b/test/test_stdin.py new file mode 100755 index 00000000..28286e09 --- /dev/null +++ b/test/test_stdin.py @@ -0,0 +1,38 @@ +#!/usr/bin/env python3 + +"""Test reading from stdin with serdi.""" + +import argparse +import sys +import shlex +import subprocess +import tempfile + +parser = argparse.ArgumentParser(description=__doc__) + +parser.add_argument("--serdi", default="./serdi", help="path to serdi") +parser.add_argument("--wrapper", default="", help="executable wrapper") + +args = parser.parse_args(sys.argv[1:]) +command = shlex.split(args.wrapper) + [args.serdi, "-"] + +DOCUMENT = "<{0}s> <{0}p> <{0}o> .".format("http://example.org/") + +with tempfile.TemporaryFile() as out: + proc = subprocess.run( + command, + check=False, + encoding="utf-8", + input=DOCUMENT, + stdout=out, + stderr=subprocess.PIPE, + ) + + assert proc.returncode == 0 + assert len(proc.stderr) == 0 + + out.seek(0) + lines = out.readlines() + + assert len(lines) == 1 + assert lines[0].decode("utf-8").strip() == DOCUMENT |