簡體   English   中英

當我執行 unittest 命令“python3 -m unittest filepath/filename.py”時,它顯示配置錯誤

[英]When i execute unittest command “python3 -m unittest filepath/filename.py” it showing improperly configured error

當我執行單元測試命令時: 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

請閱讀此https://docs.djangoproject.com/en/dev/internals/contributing/writing-code/unit-tests/#testing-other-python-versions-and-database-backends

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM