Problem running Unittest in PyCharm 1.5.4

Somehow i cannot run unittest (PyCharm 1.5.4).  Could you please help?

I am new to PyCharm and Python and sure that i am missing something... Could you please explain what is wrong and suggest how to fix it?

Steps to reproduce the error:

1. While in right-click --> popup menu: "Create unittest in models..." --> dialog: Create Rund/Debug Configuration: Unittests in

2. Accept all defauls parameters (see attached Unittest_problem_PyCharm_1.5.4.png), click Ok

3. Make sure that the current configuration is "Unittests in"

4. Shift + F10

5. Here comes the error:

C:\Python27\python.exe "C:\Program Files\JetBrains\PyCharm 1.5.4\helpers\pycharm\" true

Testing started at 4:27 PM ...

Traceback (most recent call last):

  File "C:\Program Files\JetBrains\PyCharm 1.5.4\helpers\pycharm\", line 126, in <module>

    modules = [loadSource(a[0])]

  File "C:\Program Files\JetBrains\PyCharm 1.5.4\helpers\pycharm\", line 50, in loadSource

    module = imp.load_source(moduleName, fileName)

  File "", line 9, in <module>

    from django.db import models

  File "C:\Python27\lib\site-packages\django\db\", line 14, in <module>

    if not settings.DATABASES:

  File "C:\Python27\lib\site-packages\django\utils\", line 276, in __getattr__


  File "C:\Python27\lib\site-packages\django\conf\", line 40, in _setup

    raise ImportError("Settings cannot be imported, because environment variable %s is undefined." % ENVIRONMENT_VARIABLE)

ImportError: Settings cannot be imported, because environment variable DJANGO_SETTINGS_MODULE is undefined.

Process finished with exit code 1

Thank you,



Hi Igor,

as I understand you develop Django application.

Django running its tests in a different way than unittest do.

PyCharm should not suggest you create unittest if you develop django, this is fixed in PyCharm 2.0.

Instead you should create Django tests ( in the Run menu select Edit Configurations-> Django tests and type the path to the test you want to run (in a dotted way, see )


Thank you, Catherine, for the explanations :-)



Please sign in to leave a comment.