mirror of
https://gitlab.isc.org/isc-projects/bind9.git
synced 2025-04-18 09:44:09 +03:00
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.
This commit is contained in:
parent
e0f0c557a0
commit
543ba8da5a
@ -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
|
||||
|
@ -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,
|
||||
|
Loading…
x
Reference in New Issue
Block a user