Import used to run some script code works only once --- Python defined behavior

Asked by aravind on 2017-11-02

The very first time I run utest.sikuli , the tw.sikuli test is getting executed and I am able to see the result ( report from HTML test runner ). but when I run the utest.sikuli for 2nd time. two.sikuli is not running but in result it is considering as a pass without performing the test. If I restart the sikuli IDE it is running fine for the first time, Am I using the import statement in a wrong manner ?

utest.sikuli
class SikuliUI(unittest.TestCase):
       def test_1_adminmenu(self):
            import two

two.sikuli ::
from sikuli import *
popup("Check for greyedout option in menu")
click(Pattern("1508735426497.png").targetOffset(-12,2))
assert exists(Pattern("Administration.png").exact())
popup("Match found")

Question information

Language:
English Edit question
Status:
Solved
For:
Sikuli Edit question
Assignee:
No assignee Edit question
Solved by:
aravind
Solved:
2017-11-03
Last query:
2017-11-03
Last reply:
2017-11-02
RaiMan (raimund-hocke) said : #1

import is not intended, to "run" other scripts.

Per Jython session (and the IDE is only one session) import is only done once (the first time seen).

So step back and learn, how to load and reference stuff, that is in other modules.

aravind (aravind981) said : #2

Thanks RaiMan, I got the problem in my approach.