[Django]-Running Django tests in PyCharm

36👍

Go to menu file > settings > Django Support and select correct settings file.

enter image description here

0👍

I was experiencing the same problem. I found that I was running the wrong type of test.

import unittest
class MySampleTest(unittest.TestCase):

Cause the error

django.core.exceptions.ImproperlyConfigured: Requested setting API_BASE_URL, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings.

Changing to the import to

from django.test import SimpleTestCase

Class MySampleTest(SimpleTestCase):

allowed my test to run from within pycharm.

Leave a comment