My tests were working a few hours before. But suddenly tests located in root folder/tests are giving me ModuleNotFoundError: No module named 'tests.test_*
I imported the tests.test_a in a top level python file and it worked. Any guesses why cant pytest load them?
I am asking this because this is weird that the test folder located inside root folder/some folder/tests also contains __init__.py
and they work fine. I read this question and deleted the __init__.py
and it worked. But it is confusing as to why the top level tests would not work.
The folder structure is along the lines of:
.
├── authenticate
│ ├── exceptions.py
│ ├── __init__.py
│ ├── __pycache__
│ │ ├── exceptions.cpython-38.pyc
│ │ ├── __init__.cpython-38.pyc
│ │ ├── repository.cpython-38.pyc
│ │ └── use_case.cpython-38.pyc
│ ├── Readme.md
│ ├── repository.py
│ ├── tests
│ │ ├── __init__.py
│ │ ├── __pycache__
│ │ └── test_authenticate.py
│ └── use_case.py
├── tests
│ ├── __init__.py
│ ├── __pycache__
│ │ ├── test_authenticate.cpython-38-pytest-5.4.2.pyc
│ ├── test_authenticate.py