****已解决:将__init__.py
添加到Test/
,并将testcode.py
重命名为test_code.py
。运行测试cd -> Zee
并键入pytest
****
结构:
|--Zee/
| |--Test/
| | |--__init__.py
| | |--test_code.py
| |--Codetotest/
| | |--code.py
在code.py中
class Foo():
some code...
在testcode.py中
from Codetotest.code import Foo
def test_foo():
assert ...
当我移动到命令行中的Zee
目录并运行pytest Test/testcode.py
时,我得到ModuleNotFoundError: No module named Zee
。我怎样才能解决这个问题
我尝试通过添加建议的here使测试成为一个模块。从多个目录运行,没有骰子
Pytest版本5.3.4,从python 3.6导入
我不明白的是,当我将__init__.py
添加到Zee/
时,它会给我同样的错误
在模块目录中需要一个
__init__.py
以下是一个典型的项目结构:
代码.py
测试_zee.py
相关问题 更多 >
编程相关推荐