+# Executes a command within an environment which can import the testing
+# Python modules (in `tests/utils/python`).
+run_python() {
+ local our_pythonpath="${BT_TESTS_SRCDIR}/utils/python"
+
+ if [[ $BT_TESTS_PYTHON_VERSION =~ 3.[45] ]]; then
+ # Add a local directory containing a `typing.py` to `PYTHONPATH`
+ # for Python 3.4 and Python 3.5 which either don't offer the
+ # `typing` module at all, or offer a partial one.
+ our_pythonpath="$our_pythonpath:${BT_TESTS_SRCDIR}/utils/python/typing"
+ fi
+
+ PYTHONPATH="${our_pythonpath}${PYTHONPATH:+:}${PYTHONPATH:-}" "$@"
+}
+
+# Executes a command within an environment which can import the testing
+# Python modules (in `tests/utils/python`) and the `bt2` Python package.