From 91a273e9cdeea92dc1bf2cb83fc0d226d76155f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=A0t=C4=9Bp=C3=A1n=20Bal=C3=A1=C5=BEik?= Date: Fri, 13 Feb 2026 11:53:16 +0100 Subject: [PATCH] Move pytest requirements check to pytest_configure hook Logging from a pytest hook looks better. Reorder the check for presence of `featuretest` before `init_vars` to produce more sensible errors. (cherry picked from commit b31f058ad0026ed183ac1fc9fb6fa089162301e3) --- bin/tests/system/conftest.py | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/bin/tests/system/conftest.py b/bin/tests/system/conftest.py index 14ee0ed054..e84ae19590 100644 --- a/bin/tests/system/conftest.py +++ b/bin/tests/system/conftest.py @@ -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) @@ -69,10 +62,6 @@ 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 ---------------------------- - -isctest.check.is_executable(isctest.vars.ALL["PYTHON"], "Python interpreter required") -isctest.check.is_executable(isctest.vars.ALL["PERL"], "Perl interpreter required") # ---- Fix pytest-xdist loadscope for node IDs containing "::" ---------- @@ -101,6 +90,23 @@ except ImportError: # --------------------------- 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): parser.addoption( "--noclean",