Having troubles running tests in PyCharm.
manage.py test
works fine.
But if I run test in PyCharm Django Test getting following error:
AttributeError: 'module' object has no attribute 'ROOT_URLCONF'
DJANGO_SETTINGS_MODULE=project.settings.test
Settings: project/settings/test.py
Manage Script: project/manage.py
from django.test import SimpleTestCase
from rest_framework import status
class AccountTestCase(SimpleTestCase):
def test_current_account(self):
url = '/api/accounts/current/'
response = self.client.get(url)
self.assertEqual(response.status_code, status.HTTP_301_MOVED_PERMANENTLY)
Error
packages/django/core/handlers/base.py", line 113, in get_response
urlconf = settings.ROOT_URLCONF
File "/lib/python2.7/site-packages/django/conf/__init__.py", line 56, in __getattr__
return getattr(self._wrapped, name)
File "/lib/python2.7/site-packages/django/conf/__init__.py", line 173, in __getattr__
return getattr(self.default_settings, name)
AttributeError: 'module' object has no attribute 'ROOT_URLCONF'
Would appreciate any help.
Ok got it.
You have to mark root folder in PyCharm as "sources root"
Then I guess it adds it to PYTHONPATH