pytest 运行测试函数报错的解决办法 TypeError: calling <function xxx> returned None, not a test
简介:
pytest 运行测试函数报错的解决办法 TypeError: calling <function xxx> returned None, not a test
一、Pytest 运行测试函数时报错
TypeError: calling returned None, not a test

ModuleNotFoundError: No module named ‘xxx’

二、检查测试代码结构,确认符合 pytest 的规则要求

三、解决办法
删除 pytest 的缓存文件
进入项目内部,找到缓存文件进行删除:


卸载 pytest 重新安装
pip uninstall pytest
pip install pytest

四、总结