From c0c2e0b52bb5f1b60c8d74073523e2dc0ada55e1 Mon Sep 17 00:00:00 2001 From: Simon Gerber Date: Tue, 3 Sep 2024 14:11:40 +0200 Subject: [PATCH] Update jsonnet callbacks to provide byte strings This is necessary for Jsonnet >= 0.19.0 --- commodore/postprocess/jsonnet.py | 2 +- tests/test_postprocess.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/commodore/postprocess/jsonnet.py b/commodore/postprocess/jsonnet.py index 30edd9c6..833d5c71 100644 --- a/commodore/postprocess/jsonnet.py +++ b/commodore/postprocess/jsonnet.py @@ -32,7 +32,7 @@ def _try_path(basedir: P, rel: str): if not full_path.is_file(): return full_path.name, None with open(full_path, encoding="utf-8") as f: - return full_path.name, f.read() + return full_path.name, f.read().encode("utf-8") def _import_callback_with_searchpath(search: Iterable[P], basedir: P, rel: str): diff --git a/tests/test_postprocess.py b/tests/test_postprocess.py index 99f255e1..ef0b54f0 100644 --- a/tests/test_postprocess.py +++ b/tests/test_postprocess.py @@ -399,7 +399,7 @@ def test_postprocess_jsonnet_try_path(tmp_path, full_rel): path, contents = jsonnet_pp._try_path(tmp_path, rel) assert path == testf.name - assert contents == "Test" + assert contents == b"Test" @pytest.mark.parametrize( @@ -430,7 +430,7 @@ def test_postprocess_jsonnet_import_cb(tmp_path, basedir, floc): path, contents = jsonnet_pp._import_cb(tmp_path, bdir, "test.txt") assert path == "test.txt" - assert contents == f"Test {tmp_path / floc}" + assert contents == f"Test {tmp_path / floc}".encode("utf-8") def test_postprocess_jsonnet_import_cb_notfound(tmp_path):