当前位置:网站首页>pytest接口自动化测试框架 | 使用多个fixture
pytest接口自动化测试框架 | 使用多个fixture
2022-07-26 11:40:00 【COCOgsta】
视频来源:B站《冒死上传!pytest接口自动化测试框架(基础理论到项目实战及二次开发)教学视频【软件测试】》
一边学习一边整理老师的课程内容及试验笔记,并与大家分享,侵权即删,谢谢支持!
附上汇总贴:pytest接口自动化测试框架 | 汇总_COCOgsta的博客-CSDN博客
- 如果用例需要用到多个fixture的返回数据,fixture可以返回一个元素,list或字典,然后从里面取出对应的数据
import pytest
@pytest.fixture()
def test1():
a = 'zz'
b = '123456'
print('传出a,b')
return(a,b)
def test2(test1):
u = test1[0]
p = test1[1]
assert u == 'zz'
assert p == '123456'
print('通过fixture的元组正确取出用户名和密码')
if __name__ == '__main__':
pytest.main(['-s', 'test_multi_fixtures01.py'])- 可以分成多个fixture,然后在用例中传多个fixture参数
import pytest
@pytest.fixture()
def test1():
a = 'zz'
print("\n传出a")
return a
@pytest.fixture()
def test2():
b = '123456'
print('传出b')
return b
def test_3(test1, test2):
u = test1
p = test2
assert u == 'zz'
assert p == '123456'
print("传入多个fixture参数正确")
if __name__ == '__main__':
pytest.main(['-s', 'test_multi_fixtures02.py'])边栏推荐
- 建模杂谈系列150 SCLC工程化实验3-SRule
- Esp8266 Arduino programming example - know esp8266
- 【安徽大学】考研初试复试资料分享
- Esp8266 Arduino programming example - development environment construction (based on platformio)
- 科目三 掉头与转弯
- [error reported]exception: found duplicate column (s) in the data schema: `value`;
- System call capture and analysis conclusion making system call log collection system
- Data type of SQL Server database
- 一些实用、常用、效率越来越高的 Kubernetes 别名
- An error occurred in the scrapy shell
猜你喜欢

Server memory failure prediction can actually do this!

【附下载】一款强大的Web自动化漏洞扫描工具——Xray

种种迹象表明,Apple将有望支持AV1

线上一个隐匿 Bug 的复盘

基于 Flink CDC 实现海量数据的实时同步和转换

GA-RPN:引导锚点的建议区域网络

Outsourcing for four years, abandoned

28. Implementation of file directory parsing code

安科瑞余压监控系统在住宅小区的应用方案

Leetcode / Scala - sum of two numbers, three numbers, four numbers, and N numbers
随机推荐
Database composition indexes and constraints
了解 useRef 一篇就够了
音视频技术开发周刊 | 255
【通信原理】第一章 -- 绪论
PostgreSQL在Linux和Windows安装和入门基础教程
Harbor2.2 quick check of user role permissions
Esp8266 Arduino programming example - development environment construction (based on Arduino IDE)
.....
Cohere博客:在生产环境中运行大型语言模型-推理框架概览
MongoDN数据库以URL形式连接
GA-RPN:引导锚点的建议区域网络
浅谈Web Vitals
滴滴被罚80亿!拿用户数据赚钱的时代结束了
国内11所“袖珍”大学!在校园跑步,还没加速就出校门了...
零基础小白也能懂的 Redis 数据库,手把手教你易学易用!
System call capture and segmentation - RING3 layer LD_ Preload mechanism for library function hijacking
Metauniverse gamefi chain game system development NFT Technology
专访即构科技李凯:音视频的有趣、行业前沿一直吸引着我
如何使用数据管道实现测试现代化
Swagger2.9.2 tutorial and swagger3.0.0 tutorial