Я использую virtualenv с Python 3.11.9 и pytest 8.3.2
Код: Выделить всё
ImportError: No module named 'drf.settings'
pytest-django could not find a Django project (no manage.py file could be found). You must explicitly add your Django project to the Python path to have it picked up.
Код: Выделить всё
├── README.md
├── drf
│ ├── drf
│ │ ├── __init__.py
│ │ ├── production_settings.py
│ │ ├── settings.py
│ │ ├── urls.py
│ │ └── wsgi.py
│ ├── manage.py
│ └── tests
│ ├── __pycache__
│ │ └── test_auth.cpython-311-pytest-8.3.2.pyc
│ ├── factory_boy
│ │ ├── __pycache__
│ │ │ └── factory_models.cpython-311.pyc
│ │ └── factory_models.py
│ └── test_auth.py
├── drf-uwsgi.ini
├── pytest.ini
├── requirements.in
├── requirements.txt
Код: Выделить всё
[pytest]
DJANGO_SETTINGS_MODULE = drf.settings
python_files = test_*.py
django_debug_mode = true
pythonpath = .venv/bin/python
- Я пытался добавить init.py в каталог тестов (кажется, не рекомендуется и не сработало)
- деактивируйте и повторно активируйте virtualenv
- измените drf.settings.py на drf. drf.settings, но ничего
- запустить pytest как модуль с тестами python -m pytest
в данный момент я могу запустить pytest с любой проблемой, но для этого я использую конкурс и ищу решение с помощью pytest.ini
Если у вас есть какие-либо предложения;)
Подробнее здесь: https://stackoverflow.com/questions/788 ... -directory