Importing modules from a sibling directory for use with py.test

ぃ、小莉子 提交于 2019-12-05 16:22:58

No you don't need to add anything to __init__.py. This file tells python to treat the parent directory as module which can be imported as described here. Just add it to your Title directory and import it like

from ..Tiltle.file import file1_variable

here we are moving 1 hierarchy above in the directory just like cd ..

Note .. is for reaching the Title package from test directory. If you need to run your file from ProjectName directory you will have to do

from Tiltle.file import file1_variable
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!