← Back to team overview

sikuli-driver team mailing list archive

[Question #254399]: unittest and pycharm debugging

 

New question #254399 on Sikuli:
https://answers.launchpad.net/sikuli/+question/254399

Hi all,

I'm using Sikuli 1.0.1 on Windows7/Java7 and Pycharm as IDE for debugging with :
- jython2.5.3 as Pycharm Jython interpreter
- sikuli-java.jar in a local (pycharm) CLASSPATH env variable
- sikuli-java.jar set into the sys.path
- unittest2 installed (as explained here : https://answers.launchpad.net/sikuli/+question/192876) and set into the sys.path 

My project is made up of a main.sikuli\main.py that import unittest2 suites to be run (actually .sikuli script...).

So in my main.py I just  :

import unittest2
def suite():
	modules_to_test = ('mySuite',)
	alltests = unittest2.TestSuite()
	for module in map(__import__, modules_to_test):
		alltests.addTest(unittest2.findTestCases(module))
	return alltests

if __name__ == '__main__':
	unittest2.main(defaultTest='suite', exit=False, verbosity=2)

where mySuite.sikuli\mySuite.py is :

from sikuli import *
import unittest2

class mySuite(unittest2.TestCase):

	 @classmethod
	def setUpClass(cls):
 		cls.app = App(r"C:\Program Files (x86)\myapp")
 		cls.app.open()
 		cls.mainWindow = wait("window.png", 20)
 		cls.mainWindow.highlight(3)

	def setUp(self):

	def test_bool(self):
  		assert True == True

	def tearDown(self):

	 @classmethod
	def tearDownClass(cls):
		cls.app.close()

Now, when I run the main.py everything works fine (myapp is open and the mainWindow found successfully).
But when I'm in debugging I get the following error :

Traceback (most recent call last):
  File "C:\Program Files (x86)\JetBrains\PyCharm Community Edition 3.4.1\helpers\pydev\pydevd.py", line 1733, in <module>
    debugger.run(setup['file'], None, None)
  File "C:\Program Files (x86)\JetBrains\PyCharm Community Edition 3.4.1\helpers\pydev\pydevd.py", line 1226, in run
    pydev_imports.execfile(file, globals, locals)  # execute the script
  File "C:/POC/main.sikuli/main.py", line 30, in <module>
    unittest2.main(defaultTest='suite', exit=False, verbosity=2)
  File "C:\jython2.5.3\Lib\site-packages\unittest2\main.py", line 82, in __init__
    self.module = __import__(module)
ImportError: No module named __main__

I do not understand what this __main__ module is ?

Please note that, in order to make debugging work in Pycharm, I was obliged to comment out the line 10 of the Sikuli.py (#import __main__) as explained in the https://answers.launchpad.net/sikuli/+question/253906.


Is this issue a side effect of this comment ?
Please, have you any idea ?

Thanks a lot,
Rod


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