mirror of
https://github.com/isc-projects/bind9.git
synced 2026-05-27 12:13:20 -04:00
fix: test: Use virtualenv's Python interpreter when running tests from a venv
Merge branch 'nicki/pytest-venv-python' into 'main' See merge request isc-projects/bind9!11854
This commit is contained in:
commit
4197958d03
2 changed files with 18 additions and 0 deletions
|
|
@ -402,6 +402,11 @@ def system_test_dir(request, system_test_name, expected_artifacts):
|
|||
# Log which binaries are used for the test(s)
|
||||
isctest.log.info("testing binaries from: %s", os.environ.get("TOP_BUILDDIR"))
|
||||
|
||||
# Log what Python interpreter is used to run the test(s)
|
||||
isctest.log.info(
|
||||
"using Python interpreter at: %s to run the test(s)", os.environ.get("PYTHON")
|
||||
)
|
||||
|
||||
# System tests are meant to be executed from their directory - switch to it.
|
||||
old_cwd = os.getcwd()
|
||||
os.chdir(testdir)
|
||||
|
|
|
|||
|
|
@ -11,6 +11,8 @@
|
|||
|
||||
from pathlib import Path
|
||||
|
||||
import sys
|
||||
|
||||
SYSTEM_TEST_DIR_GIT_PATH = "bin/tests/system"
|
||||
|
||||
|
||||
|
|
@ -53,6 +55,17 @@ def load_vars_from_build_files() -> dict[str, str]:
|
|||
if var_file.exists():
|
||||
build_vars[var] = var_file.read_text(encoding="utf-8").strip()
|
||||
|
||||
# When running inside a virtualenv, prefer the virtualenv's interpreter
|
||||
# over the path baked in by meson.
|
||||
# This is needed because meson is configured to prefer specific versions
|
||||
# (e.g. python3.12 and python3.11) by default to properly detect the
|
||||
# right python interpreter in CI - this is undesirable when running
|
||||
# in a virtualenv as it can lead to the system tests using the system
|
||||
# versions of Python dependencies defeating the purpose of the virtual
|
||||
# environment.
|
||||
if sys.prefix != sys.base_prefix:
|
||||
build_vars["PYTHON"] = sys.executable
|
||||
|
||||
return build_vars
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue