封装代码后通过pytest运行时报错模块没找到错误。
导入模块前面加上这2句话解决 No modlue name ‘模块名‘的报错。
import os,sys
sys.path.append(os.getcwd()) #告诉pytest运行前先检索当前路径
报错原因pytest运行时没有检索当前目录自己导入的模块。
报错截图:
原文地址:https://www.cnblogs.com/xiamaojjie/p/11515708.html
时间: 2024-08-05 12:01:34