Consider the following project structure:
a.py
test/
test_a.py
with test_a.py
importing module a
:
import a
As expected, running nosetests
in the test
directory results in import error:
ERROR: Failure: ImportError (No module named a)
However, I noticed that adding an empty __init__.py
file to the test
directory makes import work with nosetests
(but not when you run test_a.py
with Python). Could you explain why?
I understand that adding __init__.py
makes test
a package. But does it mean that import includes the directory containing the package in the lookup?