当前位置:网站首页>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
边栏推荐
- 爬虫基本原理介绍、实现以及问题解决
- More than 2022 cattle guest school game 4 yue
- Generate pictures based on the content of the specified area and share them with a summary
- LabVIEW中局部变量和全局变量的分配
- VSCode插件推荐(Rust环境)
- 【ASWC Arxml结构分解】-7-Explicit(显式)和Implicit(隐式) Sender-Receiver communication描述差异
- 2022杭电多校第二场1011 DOS Card(线段树)
- MATLAB程序设计与应用 2.5 MATLAB运算
- 目标检测概述-上篇
- 电磁兼容简明教程(6)测试项目
猜你喜欢
LabVIEW中局部变量和全局变量的分配
爆肝3万字,最硬核丨Mysql 知识体系、命令全集 【建议收藏 】
"By sharing" northwestern university life service | | bytes a second interview on three sides by HR
特别数的和
Using FiddlerScript caught poly FiddlerScript 】 【 download
奇葩问题 npm install 报错 gyp ERR
仿牛客网讨论社区项目—项目总结及项目常见面试题
crypto-js uses
阿里云李飞飞:中国云数据库在很多主流技术创新上已经领先国外
信息系统项目管理师必背核心考点(五十六)配置控制委员会(CCB)的工作
随机推荐
对于升级go1.18的goland问题
史上超强最常用SQL语句大全
Golang:go静态文件处理
C语言学习概览(二)
电磁兼容简明教程(6)测试项目
mysql中添加字段的相关问题
Guest brush SQL - 2
根据指定区域内容生成图片并进行分享总结
点餐系统数据库设计--SQL Server
Xiaobai's 0 Basic Tutorial SQL: An Overview of Relational Databases 02
旋度(7)连接失败localhost8080;连接拒绝了
Practical training Navicat Chinese and English mode switching
More than 2022 cattle guest school game 4 yue
Go 支持 OOP: 用 struct 代替 class
Image lossless compression software which works: try completely free JPG - C image batch finishing compression reduces weight tools | latest JPG batch dressing tools download
13 - JUC CountDownLatch concurrent programming
Zero-code website development tool: WordPress
return; represents meaning
Compare two objects are the same depth
Golang:go获取url和表单属性值