diff options
author | David Robillard <d@drobilla.net> | 2021-08-12 22:33:47 -0400 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2022-01-28 21:57:07 -0500 |
commit | 196db2ef0cd44c3fb542b86be7929bd01d83e138 (patch) | |
tree | 97ad345394e394c0d42b43fcf3d464794f719ccb /test/test_sort.py | |
parent | fdf837b4b3baffc65e429c2e6ecc2e764bfed0ac (diff) | |
download | serd-196db2ef0cd44c3fb542b86be7929bd01d83e138.tar.gz serd-196db2ef0cd44c3fb542b86be7929bd01d83e138.tar.bz2 serd-196db2ef0cd44c3fb542b86be7929bd01d83e138.zip |
Put rdf:type properties first when pretty-printing
This is a common convention in Turtle and TriG because the special "a" syntax
for rdf type as the first property looks nice, makes things easier to read, and
can be useful for streaming implementations because the type of the instance is
known before reading its properties.
Also significantly clean up the pretty-printing implementation in the process.
Diffstat (limited to 'test/test_sort.py')
-rwxr-xr-x | test/test_sort.py | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/test/test_sort.py b/test/test_sort.py index 4080b93c..04c8ba10 100755 --- a/test/test_sort.py +++ b/test/test_sort.py @@ -28,15 +28,17 @@ collations = [ ] -def check(test_dir, command_prefix, out_dir, input_path, name): +def check(test_dir, command_prefix, out_dir, input_path, name, flags=None): """Sort a single input in the named order and check the output. - The expected output is assumed to exist at test_dir/NAME.nq. + The expected output is assumed to exist at test_dir/NAME.untyped.nq. """ output_path = os.path.join(out_dir, name + ".nq") result_path = os.path.join(test_dir, name + ".nq") - options = [] if name == "pretty" else ["-c", name] + options = flags if flags is not None else [] + if name not in ["pretty", "untyped"]: + options += ["-c", name] # Randomly add irrelevant options just to cover them if random.choice([True, False]): @@ -68,10 +70,18 @@ def run_tests(test_dir, command_prefix, out_dir): input_trig = os.path.join(test_dir, "input.trig") n_failures = 0 + + # Test all the basic collations, and "pretty" with type first for name in collations: if not check(test_dir, command_prefix, out_dir, input_trig, name): n_failures += 1 + # Test "pretty" without type first + if not check( + test_dir, command_prefix, out_dir, input_trig, "untyped", ["-t"] + ): + n_failures += 1 + return n_failures |