diff options
author | David Robillard <d@drobilla.net> | 2019-12-18 19:16:14 -0500 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2021-03-08 23:36:32 -0500 |
commit | 0c347c9701af4595a68bb37eb7c69b5db2d452f8 (patch) | |
tree | 2c41e70b44211c00fbc0f3830db886c8d0b1b85e /test/test_grep.py | |
parent | f7c7115e0555f25e0f2c6d09378b66aec2d41d76 (diff) | |
download | serd-0c347c9701af4595a68bb37eb7c69b5db2d452f8.tar.gz serd-0c347c9701af4595a68bb37eb7c69b5db2d452f8.tar.bz2 serd-0c347c9701af4595a68bb37eb7c69b5db2d452f8.zip |
WIP: Add statement filtering
Diffstat (limited to 'test/test_grep.py')
-rw-r--r-- | test/test_grep.py | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/test/test_grep.py b/test/test_grep.py new file mode 100644 index 00000000..a4c8d91c --- /dev/null +++ b/test/test_grep.py @@ -0,0 +1,40 @@ +#!/usr/bin/env python3 + +"""Test filtering statements.""" + +import argparse +import sys +import shlex +import subprocess +import tempfile + +DOCUMENT = """<urn:example:s> <urn:example:p> <urn:example:o> . +<urn:example:s> <urn:example:q> <urn:example:r> . +""" + +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, + "-g", + "?s <urn:example:p> <urn:example:o> .", + "-s", + DOCUMENT, +] + +with tempfile.TemporaryFile() as out: + proc = subprocess.run( + command, + check=False, + encoding="utf-8", + input=DOCUMENT, + capture_output=True, + ) + + assert proc.returncode == 0 + assert len(proc.stderr) == 0 + assert proc.stdout == "<urn:example:s> <urn:example:p> <urn:example:o> .\n" |