python ddt 重写
2024-09-08 10:29:26
对此方法重写
def mk_test_name(name, value, index=0):
重写前
index = "{0:0{1}}".format(index + 1, index_len)
if not is_trivial(value):
return "{0}_{1}".format(name, index)
try:
value = str(value)
except UnicodeEncodeError:
# fallback for python2
value = value.encode('ascii', 'backslashreplace')
test_name = "{0}_{1}_{2}".format(name, index, value)
return re.sub(r'\W|^(?=\d)', '_', test_name)
重写后
# Add zeros before index to keep order
index = "{0:0{1}}".format(index + 1, index_len)
if not is_trivial(value):
if type(value) is dic and "api_name" in value.keys():
value=value["api_name"]
else:
return "{0}_{1}".format(name, index)
try:
value = str(value)
except UnicodeEncodeError:
# fallback for python2
value = value.encode('ascii', 'backslashreplace')
test_name = "{0}_{1}_{2}".format(name, index, value)
return re.sub(r'\W|^(?=\d)', '_', test_name)
重写效果:
最新文章
- asp.net配置web.config支持jQuery.Uploadify插件上传大文件
- UILabel实现自适应高宽
- Winform开发框架之读卡器和条码扫描枪的数据接收处理
- ASP.NET MVC4中使用Ninject
- 浅析C/C++ library
- Redis 配置文件 Redis.conf 参数说明
- mysql优化--博森瑞
- Raid1源代码分析--写流程
- 重写Collections实现自定义排序
- javascript:;”是什么意思
- 虚拟机Q&;A
- SD卡的控制方法(指令集和控制时序)
- 配置虚拟主机(windows环境下nginx+php)
- redis 3.2 报错 Redis protected-mode 配置文件没有真正启动
- 现有n 个乱序数,都大于 1000 ,让取排行榜前十,时间复杂度为o(n), top10, 或者 topK,应用场景榜单Top:10,堆实现Top k
- 创建dblink
- Redis五种数据结构简介-2
- Ansible 远程执行命令
- 做一个完整的Java Web项目需要掌握的技能[转]
- JS学习笔记(5)--一道返回整数数组的面试题(经验之谈)
热门文章
- RS-232针脚(8 pin)
- openWRT自学---对官方的开发指导文档的解读和理解 记录1:编译一个package
- Maven项目Update Project...后JRE System Library会自动变回1.5解决办法
- HDU 5045 5047 5050 5053(上海网络赛E,F,I,L)
- 如何创建AnjularJS项目
- Pipeline outbound
- js apply / call 函数
- 跟我一起用Symfony写一个博客网站;
- Python: generator, yield, yield from 详解
- Django与Vue语法冲突问题完美解决方法