0
我有以下結構:Python的單元測試ModuleImportFailure
project/
survey/
__init__.py
survey_state_machine.py
tests/
survey/
__init__.py
test_survey_state_machine.py
裏面survey_state_machine.py,我定義的類SurveyState,SurveyStateService,SurveyCacheOperationException。
裏面test_survey.py我有以下import語句:
from survey.survey_state_machine import SurveyStateService
from survey.survey_state_machine import SurveyState
from survey.survey_state_machine import SurveyCacheOperationException
在 「項目」 目錄中,我運行:
python3 -m unittest discover tests/
我收到:
ERROR: survey.test_survey_state_machine
(unittest.loader.ModuleImportFailure)
...
ImportError: No module named 'survey.survey_state_machine'
請提供關於故障的解釋,而不僅僅是通過鏈接 –