Unable to run unit tests inside a Google app engine project


I can run my google app engine without any issue in my pycharm project.


However when i want to debug a unit test in the same project I get this error:



Connected to pydev debugger (build 143.595)
Traceback (most recent call last):
File "/Applications/PyCharm.app/Contents/helpers/pydev/pydevd.py", line 2403, in <module>
globals = debugger.run(setup['file'], None, None, is_module)
File "/Applications/PyCharm.app/Contents/helpers/pydev/pydevd.py", line 1794, in run
launch(file, globals, locals) # execute the script
File "/Applications/PyCharm.app/Contents/helpers/pycharm/utrunner.py", line 118, in <module>
modules = loadModulesFromFolderRec(a[0])
File "/Applications/PyCharm.app/Contents/helpers/pycharm/utrunner.py", line 68, in loadModulesFromFolderRec
os.path.walk(folder, walkModules, (modules, pattern))
File "/Users/antkong/dev/zeetings/zeetings-ve/bin/../lib/python2.7/posixpath.py", line 231, in walk
func(arg, top, names)
File "/Applications/PyCharm.app/Contents/helpers/pycharm/utrunner.py", line 53, in walkModules
modules.append(loadSource(os.path.join(dirname, name)))
File "/Applications/PyCharm.app/Contents/helpers/pycharm/utrunner.py", line 41, in loadSource
module = imp.load_source(moduleName, fileName)
File "/Users/antkong/dev/project/test/service/mytest.py", line 1, in <module>
from webapp2_extras.appengine.auth.models import User
File "/usr/local/google_appengine/lib/webapp2-2.3/webapp2_extras/appengine/auth/models.py", line 13, in <module>
from ndb import model
ImportError: No module named ndb


If I add these to the begining of the file, it will work


import dev_appserver


But I should not need to add these two lines to every unit test files.  Unit tests run perfectly if I run nosetest in command line. How can I fix the exception via project settings?


I am using pycharm 5.0.1 professional edition.

Comment actions Permalink
Official comment

Hi! Please, go to 'File | Settings | Build, Execution, Deployment | Python Debugger' and turn off the option "PyQt compatible". Does it help?

Comment actions Permalink

Hey Antony,

Did you find out how to add that:

import dev_appserver

For all your tests?



Comment actions Permalink

Hi Denis,

You can define it in Settings/Preferences | Editor | File and Code Templates.


Please sign in to leave a comment.