pytest lastfailed原理
相信很多使用pytest的,都知道pytest有运行上次失败用例的参数,如下:
1 2 3 4 | --lf, --last-failed rerun only the tests that failed at the last run (or all if none failed) --ff, --failed-first run all tests, but run the last failures first. This may re-order tests and thus lead to repeated fixture setup/teardown. --nf, -- new -first run tests from new files first, then the rest of the tests sorted by file mtime |
但实际原理是什么呢?
我们还是来看看官方的说明:
1 | plugins may access the config.cache object to set / get json encodable values between pytest invocations. |
这说明会生成一个cache文件,这个文件在我们执行时会说明,如下:
用这里可以看出,这是一个隐藏文件,所以我们在pycharm中看不到。打开文件夹可以看到
再继续下去,有这样一个文件:.pytest_cache\v\cache\lastfailed
我们打开,是不是发现原来所有错误的用例都放在这里。
我们也可以通过以下几种方式验证:
仅仅收集不执行错误用例
pytest --lf --co
查看cache里的内容
pytest --cache-show
清空cache
pytest --cache-clear
Email:362299908@qq.com
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 地球OL攻略 —— 某应届生求职总结
· 提示词工程——AI应用必不可少的技术
· Open-Sora 2.0 重磅开源!
· 周边上新:园子的第一款马克杯温暖上架
2016-04-28 python requests模块中返回时间elapsed解析