From c8403f3360ba0d028700d6186c604ca95bf04c0b Mon Sep 17 00:00:00 2001 From: Noel Power Date: Thu, 27 Sep 2018 16:08:34 +0100 Subject: [PATCH] python/samba/tests: make sure samba-tool is called with ${PYTHON} Ensure python scripts are called with the python version that is defined by $PYTHON Signed-off-by: Noel Power Reviewed-by: Andrew Bartlett --- python/samba/tests/__init__.py | 3 +++ python/samba/tests/docs.py | 16 ++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/python/samba/tests/__init__.py b/python/samba/tests/__init__.py index 4ec3e31bcca..ca278b5d1c7 100644 --- a/python/samba/tests/__init__.py +++ b/python/samba/tests/__init__.py @@ -371,7 +371,10 @@ class BlackboxTestCase(TestCaseInTempDir): bindir = os.path.abspath(os.path.join(os.path.dirname(__file__), "../../../../bin")) parts = line.split(" ") if os.path.exists(os.path.join(bindir, parts[0])): + cmd = parts[0] parts[0] = os.path.join(bindir, parts[0]) + if cmd == "samba-tool" and os.getenv("PYTHON", None): + parts = [os.environ["PYTHON"]] + parts line = " ".join(parts) return line diff --git a/python/samba/tests/docs.py b/python/samba/tests/docs.py index dcb86e20aa7..e54c754a62a 100644 --- a/python/samba/tests/docs.py +++ b/python/samba/tests/docs.py @@ -178,6 +178,10 @@ class SmbDotConfTests(TestCase): self._test_empty(['bin/samba-tool', 'testparm']) def _test_default(self, program): + + if program[0] == 'bin/samba-tool' and os.getenv("PYTHON", None): + program = [os.environ["PYTHON"]] + program + failset = set() count = 0 @@ -216,6 +220,10 @@ class SmbDotConfTests(TestCase): "Parameters that do not have matching defaults:")) def _set_defaults(self, program): + + if program[0] == 'bin/samba-tool' and os.getenv("PYTHON", None): + program = [os.environ["PYTHON"]] + program + failset = set() count = 0 @@ -254,6 +262,10 @@ class SmbDotConfTests(TestCase): "Parameters that do not have matching defaults:")) def _set_arbitrary(self, program, exceptions=None): + + if program[0] == 'bin/samba-tool' and os.getenv("PYTHON", None): + program = [os.environ["PYTHON"]] + program + arbitrary = {'string': 'string', 'boolean': 'yes', 'integer': '5', 'boolean-rev': 'yes', 'cmdlist': 'a b c', @@ -377,6 +389,10 @@ class SmbDotConfTests(TestCase): "Parameters that were unexpectedly not set:")) def _test_empty(self, program): + + if program[0] == 'bin/samba-tool' and os.getenv("PYTHON", None): + program = [os.environ["PYTHON"]] + program + p = subprocess.Popen(program + ["-s", self.blankconf, "--suppress-prompt"], -- 2.34.1