pytest使用 报错记录(一)

原因:
pytest使用的环境与python运行的环境不一致

解决办法:
使用conftest.py文件
新建conftest.py
内容如下:

import os
import sys
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))
每次运行pytest前先运行conftest.py
————————————————

原文地址:https://www.cnblogs.com/1-qaz/p/14495723.html