"""Syntax-parse every first-party template so a broken tag fails the unit lane. The app only renders a handful of templates in unit tests (e.g. the login page), so a Jinja syntax error elsewhere would otherwise ship green. env.parse() checks syntax without resolving extends/includes/imports — enough to catch an unbalanced or mistyped tag across the whole template tree (e.g. the base.html layout). """ import pathlib import jinja2 import steward _REPO = pathlib.Path(steward.__file__).parent.parent _CORE_TEMPLATES = _REPO / "steward" / "templates" _PLUGINS = _REPO / "plugins" def test_all_steward_templates_parse(): env = jinja2.Environment() files = sorted(_CORE_TEMPLATES.rglob("*.html")) assert files, "no steward templates found" for f in files: env.parse(f.read_text()) # raises TemplateSyntaxError on a bad tag def test_all_plugin_templates_parse(): # First-party plugins ship templates too (host_agent fragments, docker, …); # they aren't rendered in the unit lane, so parse them here to catch a bad tag. env = jinja2.Environment() files = sorted(_PLUGINS.rglob("templates/**/*.html")) assert files, "no plugin templates found" for f in files: env.parse(f.read_text())