From: Nicki Křížek Date: Tue, 15 Apr 2025 12:16:08 +0000 (+0200) Subject: Require python-jinja2 for system tests X-Git-Tag: v9.21.8~25^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=543ba8da5a9ff45f2595a617d08d56dd281865a4;p=thirdparty%2Fbind9.git Require python-jinja2 for system tests Many of the system tests now use jinja2 template engine. Adding jinja2 as a hard dependency is preferable than potentially silently skipping many system tests. --- diff --git a/bin/tests/system/README.md b/bin/tests/system/README.md index 886ae4e61bf..ee5ce8efc1c 100644 --- a/bin/tests/system/README.md +++ b/bin/tests/system/README.md @@ -51,7 +51,7 @@ To run system tests, make sure you have the following dependencies installed: - perl - dnspython - pytest-xdist (for parallel execution) -- python-jinja2 (for tests which use jinja templates) +- python-jinja2 Individual system tests might also require additional dependencies. If those are missing, the affected tests will be skipped and should produce a message diff --git a/bin/tests/system/isctest/template.py b/bin/tests/system/isctest/template.py index 12d7970a48e..17cf7a2e1d6 100644 --- a/bin/tests/system/isctest/template.py +++ b/bin/tests/system/isctest/template.py @@ -14,7 +14,7 @@ from pathlib import Path from typing import Any, Dict, Optional, Union -import pytest +import jinja2 from .log import debug from .vars import ALL @@ -32,29 +32,13 @@ class TemplateEngine: to the environment variables set by the pytest runner). """ self.directory = Path(directory) - self._j2env = None self.env_vars = dict(env_vars) - - @property - def j2env(self): - """ - Jinja2 engine that is initialized when first requested. In case the - jinja2 package in unavailable, the current test will be skipped. - """ - if self._j2env is None: - try: - import jinja2 # pylint: disable=import-outside-toplevel - except ImportError: - pytest.skip("jinja2 not found") - - loader = jinja2.FileSystemLoader(str(self.directory)) - return jinja2.Environment( - loader=loader, - undefined=jinja2.StrictUndefined, - variable_start_string="@", - variable_end_string="@", - ) - return self._j2env + self.j2env = jinja2.Environment( + loader=jinja2.FileSystemLoader(str(self.directory)), + undefined=jinja2.StrictUndefined, + variable_start_string="@", + variable_end_string="@", + ) def render( self,