I'm trying to setup pytest and module name not being recognized

55 Views Asked by At

I'm trying to configure pytest for the first time.

When I run the command:

python -m pytest

I get the following error:


ImportError: No module named 'Socialmedia.settings.local'; 'Socialmedia.settings' is not a package

pytest-django found a Django project in C:\Users\Alon\PycharmProjects\Socialmedia (it contains manage.py) and added it to the Python path.
If this is wrong, add "django_find_project = false" to pytest.ini and explicitly manage your Python path.

pytest file:

[pytest]
DJANGO_SETTINGS_MODULE = Socialmedia.settings.local
python_files = test_*.py

Looks like the error is caused due to socialmedia not being recognized.

I tried:

Changing init file and adding the module there.

import Socialmedia
from Socialmedia import settings
__all__ = [Socialmedia, settings]

Moving to another directory from the project to the app.

the following picture shows how it looks like

Any idea how to make socialmedia accessible in this file?

UPDATE: Solved it by removing .local and changing my test.py to test_.py

0

There are 0 best solutions below