プロジェクトの構造は次のとおりです。
/root
- /crawler
- /basic
- agent.py
- settings.py
- main.py
- /tests
- /basic
- test_agent.py
- test_main.py
main.pyインポートagent.py、およびagent.pyインポートsettings.py。で実行main.pyし、インタープリターをsys.path に/root/crawler追加する/root/crawler(そこにあるため) ので、正常に動作します。main.pyagent.pyimport settings
しかし、 nose underを使用して単体テストを実行すると/root、 を除いて他のすべてのテストは問題test_agent.pyありませんsettings。
/root/crawlテスト対象のモジュールをインポートする前に内部のパスに追加すると機能test_agent.pyしますが、それは悪い習慣と見なされますよね?
もしそうなら、どのように回避するのImportErrorですか?