28 lines
944 B
Python
28 lines
944 B
Python
from pathlib import Path
|
|
|
|
from pytest import mark, raises
|
|
|
|
from jweb.content import Content
|
|
from jweb.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("jweb.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("jweb.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)
|