From e34c3252d973ca6e1eb62b66ca74599568e8d33c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicki=20K=C5=99=C3=AD=C5=BEek?= Date: Tue, 7 Apr 2026 14:43:11 +0200 Subject: [PATCH] Add _common dir to jinja2 template loader This allows include of template snippets from _common/ directory. --- bin/tests/system/isctest/template.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/bin/tests/system/isctest/template.py b/bin/tests/system/isctest/template.py index 21cc811dfb..f0668880c6 100644 --- a/bin/tests/system/isctest/template.py +++ b/bin/tests/system/isctest/template.py @@ -40,7 +40,12 @@ class TemplateEngine: self.directory = Path(directory) self.env_vars = dict(env_vars) self.j2env = jinja2.Environment( - loader=jinja2.FileSystemLoader(str(self.directory)), + loader=jinja2.FileSystemLoader( + [ + str(self.directory), + str(ALL["srcdir"]), # to allow _common/ includes + ] + ), undefined=jinja2.StrictUndefined, variable_start_string="@", variable_end_string="@", @@ -65,12 +70,13 @@ class TemplateEngine: variables which the engine was initialized with are also filled in. In case of a variable name clash, `data` has precedence. """ + available = self.j2env.list_templates() if template is None: template = f"{output}.j2.manual" - if not Path(template).is_file(): + if template not in available: template = f"{output}.j2" - if not Path(template).is_file(): - raise RuntimeError('No jinja2 template found for "{output}"') + if template not in available: + raise RuntimeError(f'No jinja2 template found for "{output}"') if data is None: data = {**self.env_vars}