]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Require python-jinja2 for system tests
authorNicki Křížek <nicki@isc.org>
Tue, 15 Apr 2025 12:16:08 +0000 (14:16 +0200)
committerNicki Křížek <nicki@isc.org>
Tue, 15 Apr 2025 14:46:54 +0000 (16:46 +0200)
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.

bin/tests/system/README.md
bin/tests/system/isctest/template.py

index 886ae4e61bff96a3f1ffce26bfddbddcdef432b1..ee5ce8efc1c3efc652e25bf38cb9a9d2fc7bed5f 100644 (file)
@@ -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
index 12d7970a48e54592d016f3021a43387774b700d0..17cf7a2e1d6f88eb3790f26516f1db7701121ad1 100644 (file)
@@ -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,