sikuli-driver team mailing list archive
-
sikuli-driver team
-
Mailing list archive
-
Message #10730
Re: [Question #194681]: Use String to call Function?
Question #194681 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/194681
RaiMan proposed the following answer:
Having these .sikuli in one directory:
# main.sikuli
modulesToRun = ("Test1", "Test2")
print("OK starting Tests in Modules")
for currentModule in modulesToRun:
print("Working with module " + currentModule)
exec("import "+ currentModule)
exec(currentModule + ".runModule()")
print("Testing ended.")
# Test1.sikuli
from sikuli import *
def runModule():
print "from Test1"
# Test2.sikuli
from sikuli import *
def runModule():
print "from Test2"
the following output is produced when running main:
OK starting Tests in Modules
Working with module Test1
from Test1
Working with module Test2
from Test2
Testing ended.
Idea: there are problems with Sikuli's import with path names like this:
path-workfolder/main.sikuli
path-workfolder/Test1/Test1.sikuli
path-workfolder/Test2/Test2.sikuli
so don't do that.
If you need a folder structure:
path-workfolder/main.sikuli
path-workfolder/Tests/Test1.sikuli
path-workfolder/Tests/Test2.sikuli
and add in main:
import os
dir = os.path.dirname(getBundlePath())
tests = os.path.join(dir, "Tests")
if not tests in sys.path: sys.path.append(tests)
--
You received this question notification because you are a member of
Sikuli Drivers, which is an answer contact for Sikuli.