From 96c41f59266a1bfcc0ca3c45bd0ecbf63e304466 Mon Sep 17 00:00:00 2001 From: Deborah Brouwer Date: Wed, 18 Dec 2024 13:00:19 -0800 Subject: [PATCH] ci: set python version 3.11 for run-pytest.sh CI tests are carried out in debian/x86_64_pyutils container which is using python version 3.11 so use this version also for local testing. This makes local testing more accurate. For example repeated double quotes in f-formatted strings will raise an error in python 3.11 but not in python 3.12. Part-of: --- .gitlab-ci/run-pytest.sh | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/.gitlab-ci/run-pytest.sh b/.gitlab-ci/run-pytest.sh index aaef5ddd7e8..b5bbff8746b 100755 --- a/.gitlab-ci/run-pytest.sh +++ b/.gitlab-ci/run-pytest.sh @@ -9,6 +9,8 @@ set -eu +PYTHON_BIN="python3.11" + if [ -z "${SCRIPTS_DIR:-}" ]; then SCRIPTS_DIR="$(dirname "${0}")" fi @@ -34,9 +36,9 @@ fi if [ "${USE_VENV:-}" == true ]; then echo "Setting up virtual environment for local testing." MESA_PYTEST_VENV="${CI_PROJECT_DIR}/.venv-pytest" - python3 -m venv "${MESA_PYTEST_VENV}" + ${PYTHON_BIN} -m venv "${MESA_PYTEST_VENV}" source "${MESA_PYTEST_VENV}"/bin/activate - python3 -m pip install --break-system-packages -r "${CI_PROJECT_DIR}/bin/ci/test/requirements.txt" + ${PYTHON_BIN} -m pip install --break-system-packages -r "${CI_PROJECT_DIR}/bin/ci/test/requirements.txt" fi LIB_TEST_DIR=${CI_PROJECT_DIR}/.gitlab-ci/tests @@ -44,7 +46,7 @@ SCRIPT_TEST_DIR=${CI_PROJECT_DIR}/bin/ci uncollapsed_section_start pytest "Running pytest" -PYTHONPATH="${LIB_TEST_DIR}:${SCRIPT_TEST_DIR}:${PYTHONPATH:-}" python3 -m \ +PYTHONPATH="${LIB_TEST_DIR}:${SCRIPT_TEST_DIR}:${PYTHONPATH:-}" ${PYTHON_BIN} -m \ pytest "${LIB_TEST_DIR}" "${SCRIPT_TEST_DIR}" \ -W ignore::DeprecationWarning \ --junitxml=artifacts/ci_scripts_report.xml \ @@ -54,7 +56,7 @@ PYTHONPATH="${LIB_TEST_DIR}:${SCRIPT_TEST_DIR}:${PYTHONPATH:-}" python3 -m \ section_end pytest section_start flake8 "flake8" -flake8 \ +${PYTHON_BIN} -m flake8 \ --config "${CI_PROJECT_DIR}/.gitlab-ci/.flake8" \ "${LIB_TEST_DIR}" "${SCRIPT_TEST_DIR}" section_end flake8