← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #206597]: Problem with importing "external" modules

 

Question #206597 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/206597

    Status: Open => Answered

RaiMan proposed the following answer:
Then the only possibility left:

exec ("import " + "Test1")

is not recognized by Sikuli's special handling of import statements for
other Sikuli scripts - it is directly processed by the Jython
interpreter, which looks for a Test1.py, which is not there.

So you have to switch your approach to Jython import combined with
setBundlePath():

saved_sys_path = [for e in sys.path] # save sys.path content

for currentModule in modulesToRun:
    currentModuleSikuli = currentModule+".sikuli"
    sys.path.append(os.path.join(testsModulePath, currentModuleSikuli))
    setBundlePath(currentModuleSikuli)
    exec("import " + currentModule)
    exec(currentModule + ".runModule()")
    sys.path = [for e in saved_sys_path] # reset sys.path

BTW:
I do not really understand this complex approach.
Why do you not use Python's unit test (see faq 1804)

-- 
You received this question notification because you are a member of
Sikuli Drivers, which is an answer contact for Sikuli.