Я пытаюсь запустить модульные тесты в своем приложении django, но я получаю следующую ошибку. Запуск приложения в порядке. Я использую pycharm 3.0.Django не может найти файл настроек при выполнении модульных тестов
C:\Users\user\my-project-env\Scripts\python.exe "K:\Program Files (x86)\JetBrains\PyCharm 3.0\helpers\pycharm\utrunner.py" C:/Users/user/PycharmProjects/my-project/my_app/ true
Testing started at 20:16 ...
Traceback (most recent call last):
File "K:\Program Files (x86)\JetBrains\PyCharm 3.0\helpers\pycharm\utrunner.py", line 113, in <module>
modules = loadModulesFromFolderRec(a[0])
File "K:\Program Files (x86)\JetBrains\PyCharm 3.0\helpers\pycharm\utrunner.py", line 63, in loadModulesFromFolderRec
os.path.walk(folder, walkModules, (modules, pattern))
File "C:\Users\user\my-project-env\lib\ntpath.py", line 259, in walk
func(arg, top, names)
File "K:\Program Files (x86)\JetBrains\PyCharm 3.0\helpers\pycharm\utrunner.py", line 51, in walkModules
modules.append(loadSource(os.path.join(dirname, name)))
File "K:\Program Files (x86)\JetBrains\PyCharm 3.0\helpers\pycharm\utrunner.py", line 40, in loadSource
module = imp.load_source(moduleName, fileName)
File "C:/Users/user/PycharmProjects/my-project/my_app/tests.py", line 8, in <module>
from django.test import TestCase
File "C:\Users\user\my-project-env\lib\site-packages\django\test\__init__.py", line 5, in <module>
from django.test.client import Client, RequestFactory
File "C:\Users\user\my-project-env\lib\site-packages\django\test\client.py", line 21, in <module>
from django.db import close_connection
File "C:\Users\user\my-project-env\lib\site-packages\django\db\__init__.py", line 11, in <module>
if settings.DATABASES and DEFAULT_DB_ALIAS not in settings.DATABASES:
File "C:\Users\user\my-project-env\lib\site-packages\django\conf\__init__.py", line 53, in __getattr__
self._setup(name)
File "C:\Users\user\my-project-env\lib\site-packages\django\conf\__init__.py", line 46, in _setup
% (desc, ENVIRONMENT_VARIABLE))
django.core.exceptions.ImproperlyConfigured: Requested setting DATABASES, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings.
Process finished with exit code 1
Awesome! Не знал, что вам нужно это делать. – James111