← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #170194]: import sikuli modules in testcases

 

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

    Status: Open => Answered

RaiMan proposed the following answer:
--1. You may need to add "from sikuli.Sikuli import *" in the module.
A .sikuli that you want to import according to the docs (http://sikuli.org/docx/globals.html#importing-other-sikuli-scripts-reuse-code-and-images), needs the statement:
from sikuli.Sikuli import *
at the beginning

--2. Non-ASCII character in file ....
It means what it says: you have some unicode characters in your file, that cannot be interpreted as ASCII.
To define a source code encoding, a magic comment must
be placed into the source files either as first or second line in the file, such as:
# coding=<encoding name>

In your case, since the .sikuli was made with IDE:
# coding=utf-8

--3. Importing in IDE test-cases
if you succeed in getting rid of the two above errors, you will have to specify the import in setUp, tearDown and every test case, where you need elements of the module, since you cannot place the import statement, so it is taken globally.

--4. So is there any possibility to import sikuli (and/or python) scripts in testcases, or is this not supported (yet)?
It is in fact supported, if you take the restrictions (mainly no global context available) into account.
There might be improvements to the IDE Test feature with rc3, but that is not yet clear.
Recommendation: If you plan serious testing with Sikuli, use Jython's unit test feature directly in normal IDE context.

BTW: be aware, that the testXXX def's are run in reverse order (last one
in source runs as first ...)

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