← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #160003]: Global variables and functions argument in unittest

 

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

    Status: Answered => Open

Sebastian is still having a problem:
It works fine, thanks RaiMan. 
How can I import functions from separate files in unit tests ? I've tried with following example : 

My functions in separate sikuli project witeMethod.sikuli :

from sikuli.Sikuli import *

def typeTxt(self, text):
 print "in typeTxt"
 type(text)

My unit test :

def importLibs(self):
 import os
 myPath = os.path.dirname(getBundlePath())
 if not myPath in sys.path: sys.path.append(myPath) 
 from writeMethod import *

def setUp(self):
 print "in setUp"
 switchApp("notepad")
 self.importLibs()

def tearDown(self):
 print "in tearDown"
 closeApp("notepad")

def test_1(self):
 print "in test1"
 wait(0.1)
 self.typeTxt("some text")
 wait(1)

I get error: 
There was 1 error:
1) test_1(org.python.proxies.__main__$unit2$4)Traceback (most recent call last):

  File "<string>", line 12, in runTest
  File "<string>", line 31, in test_1
AttributeError: 'unit2' object has no attribute 'typeTxt'

seems likes don't know my imported method. How actually should be ? 
Regards

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