]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Move pytest requirements check to pytest_configure hook 11551/head
authorŠtěpán Balážik <stepan@isc.org>
Fri, 13 Feb 2026 10:53:16 +0000 (11:53 +0100)
committerŠtěpán Balážik <stepan@isc.org>
Tue, 26 May 2026 15:24:07 +0000 (15:24 +0000)
Logging from a pytest hook looks better.

Reorder the check for presence of `featuretest` before `init_vars` to
produce more sensible errors.

bin/tests/system/conftest.py

index 60784849340b48fb6fd542f8d27a4396d957332d..ba89dc548ace5603a9a7213e14a676f162886b14 100644 (file)
@@ -34,13 +34,6 @@ import isctest
 # Silence warnings caused by passing a pytest fixture to another fixture.
 # pylint: disable=redefined-outer-name
 
-if sys.version_info[1] < 10:
-    raise RuntimeError("Python 3.10 or newer is required to run system tests.")
-
-isctest.log.init_conftest_logger()
-isctest.log.avoid_duplicated_logs()
-isctest.vars.init_vars()
-
 # ----------------------- Globals definition -----------------------------
 
 FILE_DIR = os.path.abspath(Path(__file__).parent)
@@ -56,16 +49,24 @@ PRIORITY_TESTS_RE = Re("|".join(PRIORITY_TESTS))
 SYSTEM_TEST_NAME_RE = Re(f"{SYSTEM_TEST_DIR_GIT_PATH}" + r"/([^/]+)")
 SYMLINK_REPLACEMENT_RE = Re(r"/tests_(.*)\.py")
 
-# ----------------------- Global requirements ----------------------------
+# --------------------------- pytest hooks -------------------------------
 
-isctest.check.is_executable(isctest.vars.ALL["PYTHON"], "Python interpreter required")
-isctest.check.is_executable(isctest.vars.ALL["PERL"], "Perl interpreter required")
-isctest.check.is_executable(
-    isctest.vars.ALL["FEATURETEST"],
-    "Run this first: ninja -C build system-test-dependencies",
-)
 
-# --------------------------- pytest hooks -------------------------------
+def pytest_configure(config):  # pylint: disable=unused-argument
+    if sys.version_info < (3, 10):
+        raise RuntimeError("Python 3.10 or newer is required to run system tests.")
+
+    isctest.log.init_conftest_logger()
+    isctest.log.avoid_duplicated_logs()
+    isctest.check.is_executable(
+        isctest.vars.ALL["FEATURETEST"],
+        "Run this first: ninja -C build system-test-dependencies",
+    )
+    isctest.vars.init_vars()
+    isctest.check.is_executable(
+        isctest.vars.ALL["PYTHON"], "Python interpreter required"
+    )
+    isctest.check.is_executable(isctest.vars.ALL["PERL"], "Perl interpreter required")
 
 
 def pytest_addoption(parser):