I'm new to StackOverflow, but i'm reading it a lot. Such a great site :D.
I've tried to find solution on my own, but i did not succeed. I'm trying to use IntelliJ Idea Community edition 15.1 with latest python plugin 5.0.2.143.121. Everything is working correctly as long as im running scripts as a normal run. But when i try to debug im getting ImportError:
Traceback (most recent call last):
File "C:\Users\XXXXX\.IdeaIC15\config\plugins\python\helpers\pydev\pydevd.py", line 2403, in <module>
globals = debugger.run(setup['file'], None, None, is_module)
File "C:\Users\XXXXX\.IdeaIC15\config\plugins\python\helpers\pydev\pydevd.py", line 1794, in run
launch(file, globals, locals) # execute the script
File "location to test script", line 2, in <module>
from BASECLASS
File "C:\location\__init__.py", line 7, in <module>
context_mock.mock()
File "C:\location\context_mock.py", line 26, in mock
import __main__
ImportError: No module named __main__
BASECLASS is a class from same package, but i obfuscated it, sorry company rules.
Generally, it is using Jython 2.7.0, and it works in following way: - when test script is run, in project init.py is made "hack":
try:
from __main__ import c
except ImportError:
import context_mock
context_mock.mock()
Where c is an java context. Mock method is in context_mock.py file:
def mock():
print 'Setting up local context...'
import sys
sys.path.append('')
for p in gen_grep('.+', gen_find("*.jar", "C:\\location\\lib")):
sys.path.append(p)
print sys.path
from xxxx import ConsoleResultsReporter, TestContext # FileResultsReporter
import __main__
__main__.c = TestContext(ConsoleResultsReporter())
__main__.c.put('__contextIsMocked__', True)
print "Done"
When im running debugger it stops on import main in mock() method. But when im running normal jython run it does not. Also when im debugging in Eclipse with pydev plugin, it is working correctly, thus i'm suspecting some configuration issue. (Maybe im wrong but is this the same debugger used in both IDEs?)
Any help would be appreciated.