当我执行UNITEST命令时;python3-m单元测试文件路径/filename.py“;它显示配置不正确的错误
当我执行单元测试命令时:当我执行UNITEST命令时;python3-m单元测试文件路径/filename.py“;它显示配置不正确的错误,python,python-3.x,django,unit-testing,Python,Python 3.x,Django,Unit Testing,当我执行单元测试命令时:python3-m unittest filepath/filename.py它抛出了一个配置不正确的错误,如果有人能帮忙,我们将不胜感激 错误: django.core.exceptions.ImproperlyConfigured: Requested setting INSTALLED_APPS, but settings are not configured. You must either define the environment variable DJA
python3-m unittest filepath/filename.py
它抛出了一个配置不正确的错误,如果有人能帮忙,我们将不胜感激
错误:
django.core.exceptions.ImproperlyConfigured: Requested setting INSTALLED_APPS, but
settings are not configured. You must either define the environment variable
DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings.
您需要设置运行单元测试所需的设置文件 在Linux上
$ export DJANGO_SETTINGS_MODULE=your_setting
如果运行
python-m django unittestfilepath/filename.py,请阅读此,因为当您作为子命令运行django
时,环境变量已设置