I found some questions that are similar but did not quite solve my problem (e.g. PATH issue with pytest 'ImportError: No module named YadaYadaYada')
My project is structured as follows:
MyApp
 |
 +--MyApp
 |   |
 |   +--__init__.py
 |   +--app.py
 |   +--config.py
 |
 +--tests
     |
     +--__init__.py
     +--test_app.py
in my test_app.py I import app.py, which works just fine.
from MyApp import app
but within app.py I import config.py like this.
import config
With this setup I can run the app module, but pytest fails to import 'config' and raises:
ImportError: No module named 'config'
pytest succeeds when I change the import statement in app.py to:
from MyApp import config
However, an error is raised when I try to run the app:
ImportError: No module named 'MyApp'
From reading other questions I'm confident that there is something wrong with the PYTHONPATH, I just could not figure out how to fix this.
 
    