python/samba/tests: make sure samba-tool is called with ${PYTHON}
authorNoel Power <noel.power@suse.com>
Thu, 27 Sep 2018 15:08:34 +0000 (16:08 +0100)
committerAndrew Bartlett <abartlet@samba.org>
Tue, 23 Oct 2018 03:50:25 +0000 (05:50 +0200)
Ensure python scripts are called with the python version that
is defined by $PYTHON

Signed-off-by: Noel Power <noel.power@suse.com>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
python/samba/tests/__init__.py
python/samba/tests/docs.py

index 4ec3e31bcca73d72c8cb6839d36e63782e977547..ca278b5d1c7a0b8a84ebead62f3d4ff1767d466f 100644 (file)
@@ -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
 
index dcb86e20aa7537a0556d79894a74930852317fee..e54c754a62ad8ca499950f780774030a9491b601 100644 (file)
@@ -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"],