← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #150217]: getBundlePath returns None when running unit tests from the command line

 

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

    Status: Open => Answered

RaiMan proposed the following answer:
Outside the def()'s self. cannot be used in unittest, since it is not
defined and makes IDE to hang. A unittest script should only contain
def()'s. Running a unittest script in a normal IDE run should do nothing
except reporting syntax errors.

If you need additional variables in your subsequent tests, you may
define them in setUp() using self.variable=value and reference them
using self.variable later on.

Be aware, that e.g. the normal import does not work as expected on the
script level, you have to repeat every needed import in every def(),
were the respective module features are needed.

So putting all together, you can do the following:

def setUp(self):
	self.x = "xxx"
	import os
	self.path = os.path.join(getBundlePath(), "script_subfolder")
	self.myJoin=os.path.join # stores a reference to a module function
	print "setup run"

def tearDown(self):
	print self.x
	print "tearDown run"

def testSomething(self):
	print "in test:", self.myJoin(self.path,"some_script.sikuli")

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