Skip to content

Commit

Permalink
Update jsonnet callbacks to provide byte strings
Browse files Browse the repository at this point in the history
This is necessary for Jsonnet >= 0.19.0
  • Loading branch information
simu committed Oct 28, 2024
1 parent 5280fe8 commit c0c2e0b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion commodore/postprocess/jsonnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
4 changes: 2 additions & 2 deletions tests/test_postprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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):
Expand Down

0 comments on commit c0c2e0b

Please sign in to comment.