diff --git a/myproject/conftest.py b/myproject/conftest.py new file mode 100644 index 0000000..f8649b8 --- /dev/null +++ b/myproject/conftest.py @@ -0,0 +1,16 @@ +# -*- coding: utf-8 -*- +""" +Конфигурация pytest для Django проекта с django-tenants +""" +import os +import django +from django.conf import settings + +# Устанавливаем переменную окружения для settings +os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'myproject.settings') + +# Инициализируем Django +def pytest_configure(config): + """Настройка Django перед запуском тестов""" + if not settings.configured: + django.setup() diff --git a/myproject/orders/tests.py b/myproject/orders/tests.py deleted file mode 100644 index 7ce503c..0000000 --- a/myproject/orders/tests.py +++ /dev/null @@ -1,3 +0,0 @@ -from django.test import TestCase - -# Create your tests here. diff --git a/myproject/requirements.txt b/myproject/requirements.txt index ebea27e..7ebcfd6 100644 --- a/myproject/requirements.txt +++ b/myproject/requirements.txt @@ -38,3 +38,5 @@ Unidecode==1.4.0 vine==5.1.0 wcwidth==0.2.14 whitenoise==6.6.0 +pytest==8.0.0 +pytest-django==4.7.0 diff --git a/pytest.ini b/pytest.ini new file mode 100644 index 0000000..151f5ee --- /dev/null +++ b/pytest.ini @@ -0,0 +1,11 @@ +[pytest] +DJANGO_SETTINGS_MODULE = myproject.settings +python_files = tests.py test_*.py *_tests.py +python_classes = Test* *Tests +python_functions = test_* +testpaths = myproject +pythonpath = myproject +addopts = --tb=short --strict-markers --reuse-db + +# Django database setup +django_find_project = true