from pathlib import Path from pytest import mark, raises from jwebsite.content import Content from jwebsite.context import Context @mark.parametrize("content", ["[Peter, Steven]", b"[Peter, Steven]"]) def test_load(datadir: Path, content: bytes | str) -> None: context = Context(datadir) context.load_extensions("jwebsite.extensions.yaml") context.render("test-load.html", "output.html", content=Content(Path("content.yml"), content, None)) with open(datadir / "build" / "output.html", encoding="utf-8") as ouput_file: assert ouput_file.read() == "PeterSteven" def test_load_type_error(datadir: Path) -> None: context = Context(datadir) context.load_extensions("jwebsite.extensions.yaml") with raises(ValueError): context.render("test-load.html", "output.html", content=Content(Path("content.yml"), 10, None)) with raises(ValueError): context.render("test-load.html", "output.html", content=10)