当前位置:网站首页>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边栏推荐
猜你喜欢

爬虫框架 Scrapy 详解

mysql中添加字段的相关问题

特别数的和

Information system project managers must recite the work of the core test site (56) Configuration Control Board (CCB)

Vim简介

How to generate and configure public key certificate in Alipay

Windows taskbar icon abnormal solution

爆肝3万字,最硬核丨Mysql 知识体系、命令全集 【建议收藏 】

Image lossless compression software which works: try completely free JPG - C image batch finishing compression reduces weight tools | latest JPG batch dressing tools download

matlab wind speed model wavelet filtering
随机推荐
R语言使用tidyquant包的tq_transmute函数计算持有某只股票的天、月、周收益率、ggplot2使用条形图可视化股票月收益率数据、使用百分比显示Y轴坐标数据、使用不同的色彩表征正负收益率
旋度(7)连接失败localhost8080;连接拒绝了
Fist game copyright-free music download, League of Legends copyright-free music, can be used for video creation, live broadcast
LeetCode Question of the Day (309. Best Time to Buy and Sell Stock with Cooldown)
Motion analysis and parameter optimization of crank-slider mechanism
LeetCode 415:字符串相加
JVM: Runtime Data Area - PC Register (Program Counter)
零代码网站开发利器:WordPress
NIO编程
datagrip 报错 “The specified database userpassword combination is rejected...”的解决方法
weight distribution
插入排序—直接插入排序和希尔排序
奇葩问题 npm install 报错 gyp ERR
图像基本操作的其他内容
How to generate and configure public key certificate in Alipay
Golang: go get url and form attribute value
I have three degrees, and I have five faces. I was "confessed" by the interviewer, and I got an offer of 33*15.
支付宝如何生成及配置公钥证书
特别数的和
实战演练 Navicat 中英文模式切换