nas_apps
nas_apps
-__init__.py
-environments.py
-settings.py
-urls.py
-wsgi.py
-pytest.ini
usecase1
-conf
-logs
-management
-migrations
-services
-templates
-utils
-__init__.py
-apps.py
-controllers.py
-forms.py
-models.py
-serializers.py
-urls.py
-views.py
usecase2
usecase3
tests
-fixtures
-conftest.py
-input_data.json
-test_usecase1.py
=============================================== ================ platform linux - Python 3.5.2,pytest-3.4.1,py-1.5.2,pluggy-0.6.0
- /home/.../Envs/venv/bin/python3 cachedir:.pytest_cache rootdir:/home/..../Desktop/dev2/NAS/nas_apps/tests,inifile:plugins: sanic-0.1.8,django-3.1.2,cov-2.5.1收集0件/ 1错误
=============================================== ==========================================错误
__________________________________________________________________________错误收集test_maintenance.py ___________________________________________________________________________ test_usecase1.py:17:in 来自usecase1.services.db_helper import DbHelper ../usecase1/services/db_helper.py:16:in 来自.log_service import LogRunner ../usecase1/services/log_service.py:17:in class LogRunner:../ usecase1 / services / log_service.py:18:在LogRunner中 _config_manager = ConfigManager()../ usecase1 /utils / config.py:24:在 init 中 curr_app_dir = apps.get_app_config(' usecase1')。verbose_name.lower() /home/.../Envs/uscc01/lib/python3.5/site-packages/django/apps/registry.py:145: 在get_app_config中 self.check_apps_ready()/ home /.../Envs/uscc01/lib/python3.5/site-packages/django/apps/registry.py:127: 在check_apps_ready中 提升AppRegistryNotReady("应用尚未加载。")E django.core.exceptions.AppRegistryNotReady:应用尚未加载。
有人可以帮我解决这个问题吗?感谢您的帮助。
答案 0 :(得分:1)
pytest.ini文件被错误地放到另一个apps文件夹中,理想情况下应放置在django项目文件夹的根目录中。例如平行于settings.py
content of pytest.ini:
[pytest]
DJANGO_SETTINGS_MODULE = nas_apps_proj.settings
python_files = tests.py test_*.py *_tests.py
答案 1 :(得分:0)
have you added all the apps in setting.py try this hope this resolves your concern:
Example:
setting.py
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django_user_agents',
'add_your_created_app_here',
]
答案 2 :(得分:0)
try this :
INSTALLED_APPS = [ # Rest framework 'django_filters',
'django_apscheduler',
'rest_framework',
'corsheaders',
# Project applications
'ms_vlan_failover.apps.Usecase1Config',
'maintenance_check.apps.Usecase2Config',
'reporting.apps.Usecase1Config',
# Django defaults
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'usecase1',
'usecase2',
'usecase3',
'tests',
]