PyCharm unittests only work individually
Question: I can run my test cases individually by right-clicking them and selecting `Run
'Unittests in test_whatever'` but when I right-click the project root folder
and select `Run 'Unittests in MyProject'` I get ImportErrors such as this:

    
    
    Testing started at 10:42 ...
    Traceback (most recent call last):
      File "C:\Program Files (x86)\JetBrains\PyCharm 4.5\helpers\pycharm\utrunner.py", line 113, in <module>
        modules = loadModulesFromFolderRec(a[0])
      File "C:\Program Files (x86)\JetBrains\PyCharm 4.5\helpers\pycharm\utrunner.py", line 63, in loadModulesFromFolderRec
        os.path.walk(folder, walkModules, (modules, pattern))
      File "C:\Python27\lib\ntpath.py", line 272, in walk
        walk(name, func, arg)
      File "C:\Python27\lib\ntpath.py", line 272, in walk
        walk(name, func, arg)
      File "C:\Python27\lib\ntpath.py", line 272, in walk
        walk(name, func, arg)
      File "C:\Python27\lib\ntpath.py", line 272, in walk
        walk(name, func, arg)
      File "C:\Python27\lib\ntpath.py", line 272, in walk
        walk(name, func, arg)
      File "C:\Python27\lib\ntpath.py", line 272, in walk
        walk(name, func, arg)
      File "C:\Python27\lib\ntpath.py", line 272, in walk
        walk(name, func, arg)
      File "C:\Python27\lib\ntpath.py", line 268, in walk
        func(arg, top, names)
      File "C:\Program Files (x86)\JetBrains\PyCharm 4.5\helpers\pycharm\utrunner.py", line 51, in walkModules
        modules.append(loadSource(os.path.join(dirname, name)))
      File "C:\Program Files (x86)\JetBrains\PyCharm 4.5\helpers\pycharm\utrunner.py", line 40, in loadSource
        module = imp.load_source(moduleName, fileName)
      File "C:\Users\Filip\PycharmProjects\MyProject\venv\lib\python2.7\site-packages\Crypto\SelfTest\Cipher\test_AES.py", line 29, in <module>
        from common import dict     # For compatibility with Python 2.1 and 2.2
    ImportError: No module named common
    

I'm assuming this has something to do with the working directory.

I'm running python 2.7.9. And yes, the virtualenv is in the project folder,
and on git. Don't ask.


Answer: Did you set the checkboxes _Add content roots to PYTHONPATH_ and _Add source
roots to PYTHONPATH_ in the _Run/Debug Configuration_ Dialog of pyCharm. If
not, this could help.

