Ошибка при написании unit-tests в Django
вот мои тесты:
from unittest import TestCase
import django
from django.test import Client
from django.conf import settings
import os
settings.configure(
DEBUG=True,
ROOT_URLCONF='backend.urls',
SECRET_KEY='django-insecure-b96pez8nzn!3z+++bc2+0%j2t3qf9xhmj=q7ob-4(^y(jjyr!u',
)
# django.setup()
class TestViews(TestCase):
def test_main_page_GET(self):
client = Client()
response = client.get('registration/')
self.assertEqual(response.status_code, 200)
# self.assertTemplateNotUsed(response, 'quiz_core_app/main_page.html')
def test_index(self):
client = Client()
resp = client.get('/')
self.assertEqual(resp.status_code, 200)
Очень тяжелая для меня ошибка, мучаюсь уже 3 день и все никак не могу решить, на просторах интернета крайне мало информации об этом, из всего этого выходит две ошибки, первая, если раскомментировать django.setup():
raise RuntimeError(
RuntimeError: Model class django.contrib.contenttypes.models.ContentType doesn't declare an explicit app_label and isn't in an application in INSTALLED_APPS.
а вот вторая если оставить его в комментариях:
raise AppRegistryNotReady("Apps aren't loaded yet.")
django.core.exceptions.AppRegistryNotReady: Apps aren't loaded yet.
Вот еще как выглядят мои установленные приложения в settings.py:
INSTALLED_APPS = [
'quiz_core_app.apps.QuizCoreAppConfig',
'django.contrib.contenttypes.models.ContentType',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'rest_framework',
'django_filters',
'corsheaders',
]