selftesthelpers: fix py3 tests with extra_path
authorDouglas Bagnall <douglas.bagnall@catalyst.net.nz>
Sat, 27 Oct 2018 21:53:49 +0000 (10:53 +1300)
committerDouglas Bagnall <dbagnall@samba.org>
Fri, 2 Nov 2018 02:48:52 +0000 (03:48 +0100)
If a test was supplied with extra_path, a PYTHONPATH= env variable was
prepended to the args list, but the py3_compatible clause assumed the
first args element was /usr/bin/python.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Noel Power <noel.power@suse.com>
selftest/selftesthelpers.py

index 25977efe111833be9564cf55acd4a4b251b02e29..b0fc79bd18e1357a33b27c0364422cb7b9ff69ed 100644 (file)
@@ -136,18 +136,21 @@ def planperltestsuite(name, path):
         skiptestsuite(name, "Test::More not available")
 
 
-def planpythontestsuite(env, module, name=None, extra_path=[], py3_compatible=False):
+def planpythontestsuite(env, module, name=None, extra_path=None,
+                        py3_compatible=False):
     if name is None:
         name = module
-    pypath = list(extra_path)
     args = [python, "-m", "samba.subunit.run", "$LISTOPT", "$LOADLIST", module]
-    if pypath:
-        args.insert(0, "PYTHONPATH=%s" % ":".join(["$PYTHONPATH"] + pypath))
-    plantestsuite_loadlist(name, env, args)
+    if extra_path:
+        pypath = ["PYTHONPATH=$PYTHONPATH:%s" % ":".join(extra_path)]
+    else:
+        pypath = []
+
+    plantestsuite_loadlist(name, env, pypath + args)
     if py3_compatible and extra_python is not None:
         # Plan one more test for Python 3 compatible module
         args[0] = extra_python
-        plantestsuite_loadlist(name + ".python3", env, args)
+        plantestsuite_loadlist(name + ".python3", env, pypath + args)
 
 
 def get_env_torture_options():