]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
selftest: add option to pass args to tests to planpythontestsuite()
authorBjörn Baumbach <bb@sernet.de>
Fri, 24 Jul 2020 10:18:11 +0000 (12:18 +0200)
committerStefan Metzmacher <metze@samba.org>
Thu, 17 Dec 2020 13:59:38 +0000 (13:59 +0000)
The logic is basically a copy from planoldpythontestsuite().

Pair-Programmed-With: Stefan Metzmacher <metze@samba.org>

Signed-off-by: Björn Baumbach <bb@sernet.de>
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
selftest/selftesthelpers.py

index 1afabf3cdcad2de15abe4440ac6c583728e691d6..7b4c084b6de5963d61f2c144319b6d87f084a803 100644 (file)
@@ -135,16 +135,18 @@ def planperltestsuite(name, path):
         skiptestsuite(name, "Test::More not available")
 
 
-def planpythontestsuite(env, module, name=None, extra_path=None):
+def planpythontestsuite(env, module, name=None, extra_path=[], environ={}, extra_args=[]):
+    environ = dict(environ)
+    py_path = list(extra_path)
+    if py_path is not None:
+        environ["PYTHONPATH"] = ":".join(["$PYTHONPATH"] + py_path)
+    args = ["%s=%s" % item for item in environ.items()]
+    args += [python, "-m", "samba.subunit.run", "$LISTOPT", "$LOADLIST", module]
+    args += extra_args
     if name is None:
         name = module
-    args = [python, "-m", "samba.subunit.run", "$LISTOPT", "$LOADLIST", module]
-    if extra_path:
-        pypath = ["PYTHONPATH=$PYTHONPATH:%s" % ":".join(extra_path)]
-    else:
-        pypath = []
 
-    plantestsuite_loadlist(name, env, pypath + args)
+    plantestsuite_loadlist(name, env, args)
 
 
 def get_env_torture_options():