当前位置:网站首页>pytest接口自动化测试框架 | parametrize中ids的用法
pytest接口自动化测试框架 | parametrize中ids的用法
2022-08-01 07:12:00 【COCOgsta】
视频来源:B站《冒死上传!pytest接口自动化测试框架(基础理论到项目实战及二次开发)教学视频【软件测试】》
一边学习一边整理老师的课程内容及试验笔记,并与大家分享,侵权即删,谢谢支持!
附上汇总贴:pytest接口自动化测试框架 | 汇总_COCOgsta的博客-CSDN博客
import pytest
@pytest.mark.parametrize('a,b,c', [(1,1,1),(2,2,0),(3,3,1),(4,4,0)],
ids=['用例一','用例二','用例三','用例四'])
def test_1(a,b,c):
print(a,b,c)
if __name__ == '__main__':
pytest.main(['-v','-s', 'test_ids.py'])
ids参数用例描述有中文编码问题,2种解决办法:
- 在conftest中使用pytest_collection_modifyitems钩子函数,对输出的item.name和item.nodeid重新编码。
def pytest_collection_modifyitems(items):
'''
测试用例收集完成时,将收集到的item的name和nodeid的中文显示在控制台上
'''
for item in items:
item.name = item.name.encode("utf-8").decode("unicode_escape")
print(item.nodeid)
item._nodeid = item.nodeid.encode("utf-8").decode("unicode_escape")
- pytest.ini
[pytest]
disable_test_id_escaping_and_forfeit_all_rights_to_community_support = True
边栏推荐
猜你喜欢
Sound Signal Processing Fundamental Frequency Detection and Time-Frequency Analysis
Fist game copyright-free music download, League of Legends copyright-free music, can be used for video creation, live broadcast
金山打字通 官网 下载
Golang:go模版引擎的使用
Practical training Navicat Chinese and English mode switching
Three aspects of Ali: How to solve the problem of MQ message loss, duplication and backlog?
mysql的行锁和间隙锁
special day to remember
小程序通过云函数操作数据库【使用get取数据库】
我说过无数遍了:从来没有一种技术是为灵活组合这个目标而设计的
随机推荐
MATLAB program design and application of MATLAB 2.5
JVM: Runtime Data Area - PC Register (Program Counter)
POJ2421道路建设题解
表的创建、修改与删除
return; represents meaning
从底层结构开始学习FPGA(6)----分布式RAM(DRAM,Distributed RAM)
LabVIEW中局部变量和全局变量的分配
LeetCode 0149. Maximum number of points on a line
Three aspects of Ali: How to solve the problem of MQ message loss, duplication and backlog?
上课作业(7)——#598. 取余运算(mod)
零代码网站开发利器:WordPress
curl (7) Failed connect to localhost8080; Connection refused
Dart 异常详解
The BP neural network based on MATLAB voice characteristic signal classification
mysql中添加字段的相关问题
rhcsa 第四天
Dell PowerEdge Server R450 RAID Configuration Steps
Generate pictures based on the content of the specified area and share them with a summary
Upgrade to heavyweight lock, lock reentrancy will lead to lock release?
配置我的kitty