Pytest 命令行
addopts = -q --disable-warnings --html=./report/report.html --self-contained-html --capture=sys --show-capture=stderr
乱码解决过程记录:查阅资料-阅读源码-修改源码为gb2312
caputure参数
Pytest测试报告
Pytest日志
Pytest运行参数
fixture总结
zhuanlan.zhihu.com/p/564168267
fixture参数
fixture之request参数
confest.py总结
pytest.ini总结
hook函数
hook函数装饰器hookwrapper
测试框架
接口测试框架:github.com/ae86sen/api…
插件开发
pytest插件通过hook函数来实现,pytest主要包括以下三种插件
- 内置插件:pytest内部的_pytest目录中加载:
\Lib\site-packages_pytest\hookspec.py - 外部插件:pip install 插件,通过setuptools的Entry points机制来发现外部插件,可用插件列表:docs.pytest.org/en/latest/r…
- 本地插件:conftest.py插件,pytest自动模块发现机制,在项目根目录下的conftest文件起到全局作用,在项目下的子目录中的conftest.py文件作用范围只能在该层级及以下目录生效。
他们的加载顺序为:
- 内置插件
- 外部插件
- 本地插件
参考博客:www.cnblogs.com/hiyong/p/14…
hook
参考博客:segmentfault.com/a/119000001…
hookspec和hookimpl的区别