- Регистрация
- 1 Мар 2015
- Сообщения
- 3,369
- Баллы
- 155
Hi everyone,
I'm facing an issue while running Pytest in my FastAPI project, and I would appreciate any guidance. Here's the situation:
thor_software/
├── app/
│ ├── init.py
│ ├── base.py
│ ├── database.py
│ ├── models/
│ │ ├── init.py
│ │ ├── models.py
│ │ ├── schemas.py
├── Tests/
│ ├── init.py
│ ├── test_auth.py
│ ├── test_company_routes.py
├── main.py
When I run pytest in the Test/ directory, I encountered the following error:
ModuleNotFoundError: No module named 'app.models'
What I have done:
What I Need:
Why might Pytest not recognize app.models, even though the PYTHONPATH is correctly set?
Could the case sensitivity of the file system be affecting the imports?
Any suggestions on how to debug or resolve this issue?
I'm facing an issue while running Pytest in my FastAPI project, and I would appreciate any guidance. Here's the situation:
thor_software/
├── app/
│ ├── init.py
│ ├── base.py
│ ├── database.py
│ ├── models/
│ │ ├── init.py
│ │ ├── models.py
│ │ ├── schemas.py
├── Tests/
│ ├── init.py
│ ├── test_auth.py
│ ├── test_company_routes.py
├── main.py
When I run pytest in the Test/ directory, I encountered the following error:
ModuleNotFoundError: No module named 'app.models'
What I have done:
- Set PYTHONPATH to the project directory.
- Confirmed that the app directory contains an init.py file.
Verified the imports in my code. For example:
from app.models import User, Company
Checked that my file system is APFS (case-insensitive). My project folder name appears as thor_software in the terminal, but in VSCode, it's displayed as THOR_SOFTWARE. Not sure if this is related.
What I Need:
Why might Pytest not recognize app.models, even though the PYTHONPATH is correctly set?
Could the case sensitivity of the file system be affecting the imports?
Any suggestions on how to debug or resolve this issue?