aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xscripts/check_formatting.py2
-rwxr-xr-xscripts/serd_bench.py7
-rwxr-xr-xtest/run_suite.py8
-rw-r--r--test/serd_test_util/__init__.py12
-rwxr-xr-xtest/test_quiet.py8
-rwxr-xr-xtest/test_write_error.py10
6 files changed, 31 insertions, 16 deletions
diff --git a/scripts/check_formatting.py b/scripts/check_formatting.py
index e3342603..27daebe5 100755
--- a/scripts/check_formatting.py
+++ b/scripts/check_formatting.py
@@ -20,7 +20,7 @@ def run_formatter(command, good_path):
"""Run the formatter and compare the output."""
with subprocess.Popen(
- command, stderr=DEVNULL, stdout=PIPE, encoding="utf-8"
+ command, encoding="utf-8", stderr=DEVNULL, stdout=PIPE
) as proc:
out = list(proc.stdout)
diff --git a/scripts/serd_bench.py b/scripts/serd_bench.py
index d964984f..8e176322 100755
--- a/scripts/serd_bench.py
+++ b/scripts/serd_bench.py
@@ -192,10 +192,13 @@ def run(progs, n_min, n_max, step):
with open(filename(n) + ".out", "w") as out:
sys.stderr.write(cmd + "\n")
proc = subprocess.Popen(
- cmd.split(), stdout=out, stderr=subprocess.PIPE
+ cmd.split(),
+ encoding="utf-8",
+ stdout=out,
+ stderr=subprocess.PIPE,
)
- time, memory = parse_time(proc.communicate()[1].decode())
+ time, memory = parse_time(proc.communicate()[1])
rows["time"] += ["%.07f" % time]
rows["throughput"] += ["%d" % (n / time)]
rows["memory"] += [str(memory)]
diff --git a/test/run_suite.py b/test/run_suite.py
index 3811a74e..84c74dd1 100755
--- a/test/run_suite.py
+++ b/test/run_suite.py
@@ -1,6 +1,6 @@
#!/usr/bin/env python3
-# Copyright 2022-2023 David Robillard <d@drobilla.net>
+# Copyright 2022-2025 David Robillard <d@drobilla.net>
# SPDX-License-Identifier: ISC
"""Run a "simple" one-pass RDF-based test suite for serd."""
@@ -43,7 +43,7 @@ def run_eval_test(base_uri, command, in_path, good_path, out_path):
syntax = util.syntax_from_path(out_path)
command = command + ["-o", syntax, in_path, base_uri]
- with subprocess.Popen(command, stdout=PIPE, encoding="utf-8") as proc:
+ with subprocess.Popen(command, encoding="utf-8", stdout=PIPE) as proc:
out = list(proc.stdout)
with open(good_path, "r", encoding="utf-8") as good:
@@ -65,7 +65,9 @@ def run_negative_test(base_uri, command, in_path, ignore):
raise RuntimeError("Input file missing: " + in_path)
command = command + [in_path, base_uri]
- proc = subprocess.run(command, check=False, stderr=PIPE, stdout=DEVNULL)
+ proc = subprocess.run(
+ command, check=False, encoding="utf-8", stderr=PIPE, stdout=DEVNULL
+ )
if not ignore and proc.returncode == 0:
util.error("Unexpected successful return: " + in_path)
diff --git a/test/serd_test_util/__init__.py b/test/serd_test_util/__init__.py
index ad417762..c38100b5 100644
--- a/test/serd_test_util/__init__.py
+++ b/test/serd_test_util/__init__.py
@@ -1,6 +1,6 @@
#!/usr/bin/env python3
-# Copyright 2022-2023 David Robillard <d@drobilla.net>
+# Copyright 2022-2025 David Robillard <d@drobilla.net>
# SPDX-License-Identifier: ISC
"""Utilities for data-driven tests."""
@@ -157,12 +157,14 @@ def load_rdf(filename, base_uri, command_prefix):
cmd = command_prefix + [filename, base_uri]
proc = subprocess.run(
- cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, check=True
+ cmd,
+ encoding="utf-8",
+ stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE,
+ check=True,
)
for line in proc.stdout.splitlines():
- matches = re.match(
- r"<([^ ]*)> <([^ ]*)> <([^ ]*)> \.", line.decode("utf-8")
- )
+ matches = re.match(r"<([^ ]*)> <([^ ]*)> <([^ ]*)> \.", line)
if matches:
s, p, o = (matches.group(1), matches.group(2), matches.group(3))
if s not in model:
diff --git a/test/test_quiet.py b/test/test_quiet.py
index 676284bb..ff53e26e 100755
--- a/test/test_quiet.py
+++ b/test/test_quiet.py
@@ -1,6 +1,6 @@
#!/usr/bin/env python3
-# Copyright 2022 David Robillard <d@drobilla.net>
+# Copyright 2022-2025 David Robillard <d@drobilla.net>
# SPDX-License-Identifier: ISC
"""Test quiet command-line option."""
@@ -13,7 +13,11 @@ import serd_test_util as util
args = util.wrapper_args(__doc__, True)
command = shlex.split(args.wrapper) + [args.serdi, "-q", args.input]
proc = subprocess.run(
- command, check=False, stdout=subprocess.PIPE, stderr=subprocess.PIPE
+ command,
+ encoding="utf-8",
+ check=False,
+ stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE,
)
assert proc.returncode != 0
diff --git a/test/test_write_error.py b/test/test_write_error.py
index b62f981a..93b0249a 100755
--- a/test/test_write_error.py
+++ b/test/test_write_error.py
@@ -1,6 +1,6 @@
#!/usr/bin/env python3
-# Copyright 2022-2023 David Robillard <d@drobilla.net>
+# Copyright 2022-2025 David Robillard <d@drobilla.net>
# SPDX-License-Identifier: ISC
"""Test errors writing to a file."""
@@ -18,11 +18,15 @@ command = shlex.split(args.wrapper) + [args.serdi, args.input]
if os.path.exists("/dev/full"):
with open("/dev/full", "w", encoding="utf-8") as out:
proc = subprocess.run(
- command, check=False, stdout=out, stderr=subprocess.PIPE
+ command,
+ encoding="utf-8",
+ check=False,
+ stdout=out,
+ stderr=subprocess.PIPE,
)
assert proc.returncode != 0
- assert "error" in proc.stderr.decode("utf-8")
+ assert "error" in proc.stderr
else:
sys.stderr.write("warning: /dev/full not present, skipping test")