当前位置:网站首页>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

边栏推荐
猜你喜欢

puzzle(022.1)黑白迭代

SRv6网络的安全解决方案

自从新来了个字节20K出来的,就见识到了什么是天花板

2022年全网最全接口自动化测试框架搭建,没有之一

养殖虚拟仿真软件提供高沉浸式的虚拟场景互动操作体验学习

Leaflets of three bouquet of roses
![[Mock Interview - 10 Years of Work] Are more projects an advantage?](/img/fa/2652629d1ff4653aca0d626ac89bf8.jpg)
[Mock Interview - 10 Years of Work] Are more projects an advantage?

BUG | 接口返回异常数据

【3D建模制作技巧分享】ZBrush模型如何添加不同材质

【字符串函数内功修炼】strlen + strstr + strtok + strerror(三)
随机推荐
双非读者,一举拿下阿里、字节、美团、京东、虾皮offer
智慧养老整体解决方案
Leaflets of three bouquet of roses
2022年全网最全接口自动化测试框架搭建,没有之一
CS8416国产替代DP8416 数字音频接收器
【内存操作函数内功修炼】memcpy + memmove + memcmp + memset(四)
使用cpolar优化树莓派上的网页(1)
【2020】【论文笔记】超表面:多功能和可编程——
【模拟面试-10年工作】项目多一定是优势吗?
PowerBI scripture series
How to make a video gif?Try this video making gif artifact
2022精选最新金融银行面试真题——附带答案
论文解读(PPNP)《Predict then Propagate: Graph Neural Networks meet Personalized PageRank》
文章占位 文章占位
【3D建模制作技巧分享】ZBrush纹理贴图怎么导入
剑指Offer | 数值的整数次方
测试薪资这么高?刚毕业20K,仅需3.5个月
enumerate()函数
被领导拒绝涨薪申请,跳槽后怒涨9.5K,这是我的心路历程
【3D建模制作技巧分享】ZBrush如何设置笔刷快捷键