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

Golang: go static file processing

Golang: go get url and form attribute value

Three aspects of Ali: How to solve the problem of MQ message loss, duplication and backlog?

Windows taskbar icon abnormal solution

响应式织梦模板园林花卉类网站

LeetCode 0149. Maximum number of points on a line

MATLAB程序设计与应用 2.5 MATLAB运算

How to use Photoshop to composite star trail photos, post-processing method of night sky star trail photos

How to generate and configure public key certificate in Alipay

「面经分享」西北大学 | 字节 生活服务 | 一面二面三面 HR 面
随机推荐
Practical training Navicat Chinese and English mode switching
升级为重量级锁,锁重入会导致锁释放?
Image lossless compression software which works: try completely free JPG - C image batch finishing compression reduces weight tools | latest JPG batch dressing tools download
How to use Photoshop to composite star trail photos, post-processing method of night sky star trail photos
weight distribution
Guest brush SQL - 2
点餐系统数据库设计--SQL Server
LeetCode 0150. Reverse Polish Expression Evaluation
问下 mysql向pg同步多个表的话 有什么好的方案吗?
Zero-code website development tool: WordPress
Classwork (7) - #598. remainder operation (mod)
crypto-js uses
并发编程13-JUC之CountDownLatch
电磁兼容简明教程(6)测试项目
基于百度OCR的网站验证码在线识别
Go 支持 OOP: 用 struct 代替 class
matlab wind speed model wavelet filtering
Golang: go get url and form attribute value
POJ2421道路建设题解
Vim三种模式