当前位置:网站首页>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
边栏推荐
- 学生管理系统架构设计
- 2022七夕程序员必备的表白黑科技(七夕限定款)
- Reconfigure the ffmpeg plugin in chrome
- 【字符串函数内功修炼】strcpy + strcat + strcmp(一)
- [Mock Interview - 10 Years of Work] Are more projects an advantage?
- Linux系统重启和停止Mysql服务教程
- SSM整合完整流程讲解
- DREAMWEAVER8 part of the problem solution
- 基于事实的讨论
- synchronized和ReentrantLock都很丝滑,因为他们都是可重入锁,一个线程多次拿锁也不会死锁,我们需要可重入
猜你喜欢
随机推荐
xss总结
地面高度检测/平面提取与检测(Fast Plane Extraction in Organized Point Clouds Using Agglomerative Hierarchical Clu)
FinClip崁入式搭建生态平台,降低合作门槛
重新配置chrome中ffmpeg插件
ANT1.7下载以及配置方法
养殖虚拟仿真软件提供高沉浸式的虚拟场景互动操作体验学习
期货开户哪个平台好,要正规安全的
【游戏建模模型制作全流程】使用ZBrush制作骷髅王
QT[一] 信号与槽
【C - 基本概念】
Shell编程之循环语句与函数的使用
深度学习 RNN架构解析
单片机原理[一] 学好单片机必会的五张图
Redis中的LRU算法
软测人面试 ,HR 会问到哪些问题?学会涨薪3000+
ANT1.7 download and configuration method
Qt中的常用控件
基于内容的图像检索系统设计与实现--颜色信息--纹理信息--形状信息--PHASH--SHFT特征点的综合检测项目,包含简易版与完整版的源码及数据!
DREAMWEAVER8 部分问题解决方案
祝福一路顺风