When run a test with python mycore/tests4extractor.py
it works. If run the test with nosetests ./mycore/tests4extractor.py
it fails with ImportError: No module named extractor
. I am in the helpers
folder.
The project structure is:
helpers/
mycore/
__init__.py
extractor.py
tests4extractor.py
Setting PYTHONPATH to the absolute path to helpers
and/or helpers/mycore
doesn't help.
Answer
tests4extractor.py:
import mycore
from extractor import extract
should be changed to:
import mycore
from mycore.extractor import extract
And python should be run with python -mmycore.tests4_strings
Does
tests4extractor.py
containimport extractor
?Because
mycore
is a package, you need to use absolute imports:or relative imports: