pytest--fixure前置执行一个函数
2024-09-21 15:48:24
import pytest
@pytest.fixture()
def login_r():
print('登陆') @pytest.fixture()
def open_browser():
print('打开浏览器') def test_soso():
print('case3') @pytest.mark.usefixtures('login_r')----通过usefixtures可以让test_cart前置执行login
def test_cart():
print('case4') if __name__ == '__main__':
pytest.main()
pytest_twofixture.py::test_soso PASSED [ 50%]case3
pytest_twofixture.py::test_cart 登陆
PASSED [100%]case4
案例2
import pytest
@pytest.fixture()
def login_r(open_browser):
print('登陆') @pytest.fixture()
def open_browser():
print('打开浏览器') def test_soso():
print('case3') @pytest.mark.usefixtures('login_r')
def test_cart():
print('case4') if __name__ == '__main__':
pytest.main()
pytest_twofixture.py::test_soso PASSED [ 50%]case3
pytest_twofixture.py::test_cart 打开浏览器
登陆
PASSED [100%]case4
最新文章
- Javascript获取URL地址变量参数值的方法
- 屌炸天实战 MySQL 系列教程(二) 史上最屌、你不知道的数据库操作
- QML插件扩展2(基于C++的插件扩展)
- test命令
- .Net上传文件大小配置
- PHP5.6+7代码性能加速-开启Zend OPcache-优化CPU
- springMVC(6)---处理模型数据
- Docker笔记——jdk镜像制作
- (二)Javascript面向对象编程:构造函数的继承
- 基于vue2.0 +vuex+ element-ui后台管理系统:包括本地开发调试详细步骤
- Capture HTML Canvas as gif/jpg/png/pdf?
- 21 MRO C3算法
- Thinkphp路由使用
- hive中数据存储格式对比:textfile,parquent,orc,thrift,avro,protubuf
- svn问题汇总
- UVA12558 Egyptian Fractions (HARD version) (埃及分数,迭代加深搜索)
- python实现将json数据以json格式写入txt文件
- 题解【bzoj4587 &; bzoj4408 [FJOI2016]神秘数】
- OpenGL 模型视图投影矩阵 仿射矩阵
- VS2010安装HTML5插件