Serd subproject with meson
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

39 lines
911 B

#!/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