I know Python imports are a perennial headache, but I can't see why this should be broken:
I have the following file structure:
webapp/
README.md
...
webapp/
__init__.py
...
tests/
__init__.py
test_integration.py
webapp/init.py is initializing a Flask project, and webapp/tests/test_integration.py is trying to test the homepage.
When I cd
into webapp/webapp
and run python tests/test_integration.py
(which includes the line import webapp
), I get the error ImportError: No module named webapp
. I tried cd
ing up one directory, into the upper webapp
, as well as down into tests
, but same deal. I tried adding the absolute path to the inner webapp
directory to PYTHONPATH, but no avail.
This is strange, since I'm using a similar structure in another project and it seems to be working fine.
Also, if I move test_integration.py
all the way up into the outer webapp
directory, it runs just fine. Any reason why the test can't import webapp
from any further inside the file tree?
Any insight? Thanks!~