sikuli-driver team mailing list archive
-
sikuli-driver team
-
Mailing list archive
-
Message #03724
Re: [Question #163277]: Using images from dictionaries in unit tests
Question #163277 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/163277
Status: Open => Answered
RaiMan proposed the following answer:
Using the test feature in the IDE is a bit tricky, when trying to use
import, user defined functions to be used in the test cases or global
variables.
On top, if any errors happen that are not assert exceptions, the test
might hang (as in your case, see bug 803795).
So in the moment it is recommended to use Pythons unittest module
yourself and run your tests as a normal Sikuli script, if you want to do
more complex things. So you have full control on everything.
The problem in your case is the placement of the import statement: in
the IDE tests, this cannot be used as usual:
The general workaround is:
- there is a utestsub.sikuli
- containing a subtest() function
def setUp(self):
dir = "path-to-your-module-directory"
if not dir in sys.path: sys.path.append(dir)
def test1(self):
import utestsub
utestsub.subtest()
assert(True)
the import statement has to be placed in every testXXX, where functions/variables from the respective module are needed.
the managment of sys.path is implemented in setUp(), which is run before every test case, so you do not need it in every testXXX.
--
You received this question notification because you are a member of
Sikuli Drivers, which is an answer contact for Sikuli.