我无法以我想要的方式导入我的模块进行测试。我在2.7.2的虚拟机上运行所有这些
我有一个目录结构
/api
/api
__init__.py
my_module.py
/tests
my_module_test.py
我将PYTHONPATH设置为/Path/api/。将CD放入/Path/api并运行以下命令
^{pr2}$在以下情况下不起作用:
from api.my_module import my_function
它在以下情况下有效:
from my_module import my_function
为什么我不能像案例1那样导入我的模块?在
从py文本文档,您应该先安装:
我用PYTHONPATH作为
我创造这个是为了回答你的问题和我自己的困惑。我希望有帮助。注意
py.test
命令行和tox.ini
中的PYTHONPATH
。在示例项目是here,并且如下所示:
mymodule.py
:
^{pr2}$tests/text_syntax_errors.py
:tox.ini
:requirements.txt
:来自我的
README.md
:py.测试
毒物
相关问题 更多 >
编程相关推荐