当前位置:网站首页>Pytest learning - fixtures
Pytest learning - fixtures
2022-08-04 22:49:00 【51CTO】
1. Fixture details
1.fixture concept fixture is used by pytest to prepare before and after the test (do some pre-steps before running the test case), clean up (deal with the garbage data generated by the test)Code processing mechanism
2, fixture has the following advantages over setup and teardown:
·fixture naming is more flexible and less restrictive
·Data sharing can be realized in the conftest.py configuration, and some configurations can be automatically found without importing
Second, the fixture (@pytest.fixture)
##fixture scope priority (session>module>class>function)
1, (scop = "function") every function or method will be called
Which method you want to use prepend, call it directly
scop= "" (default is function)

2, (scop = "class ") each class is called once
Note that if there is no autouse=true (meaning that all current methods use the pre-method), the pre-method will not be executed

3, (scop = "module") called once per .py file
No matter how many methods or classes are called, they are only executed once in the current .py file

4, (scop = "session") is called once by multiple files, and the .py file is the module
Need to be used in conjunction with conftest.py, only execute once, execute at the beginning

边栏推荐
猜你喜欢

「津津乐道播客」#397 厂长来了:怎样用科技给法律赋能?

基于内容的图像检索系统设计与实现--颜色信息--纹理信息--形状信息--PHASH--SHFT特征点的综合检测项目,包含简易版与完整版的源码及数据!

湖仓一体电商项目(五):内网穿透工具-网云穿

被领导拒绝涨薪申请,跳槽后怒涨9.5K,这是我的心路历程
软件测试外包公司怎么样?有什么好处和坏处?为什么没人去?

移动web开发03

双非读者,一举拿下阿里、字节、美团、京东、虾皮offer

3D建模师为了让甲方爸爸过稿,还可以这么做,就是在赚血汗钱啊

BUG | 接口返回异常数据

【2020】【Paper Notes】Metasurfaces: Multifunctional and Programmable——
随机推荐
postman接口测试
VC bmp文件总结
3D建模师为了让甲方爸爸过稿,还可以这么做,就是在赚血汗钱啊
【3D建模制作技巧分享】ZBrush模型制作流程:地精
CS8416国产替代DP8416 数字音频接收器
【3D建模制作技巧分享】ZBrush如何重新拓扑
限制tensorflow使用Cpu核数
BUG | 接口返回异常数据
从“草原牛”到“数字牛”:蒙牛的数字化转型之道
Shell编程之循环语句与函数的使用
Latex fast insert author ORCID
【3D建模制作技巧分享】zbrush贴图映射小技巧
typeScript-promise
the warmest home
【字符串函数内功修炼】strlen + strstr + strtok + strerror(三)
历史上的今天:PHP公开发布;iPhone 4 问世;万维网之父诞生
【TCP/IP 五 ICMP】
【游戏建模模型制作全流程】在ZBrush中雕刻恶魔城男性角色模型
How to right use of WebSocket in project
力扣24-两两交换链表中的节点——链表