我们利用参数化,当传入的参数有中文的时候,展示的是\u6d4b 这样的编码,而不是显示我们要的中文,allure里面展示的也是编码。
如下代码为测试用例,ids=test_expend_data.test_smokecase_titles 传入的是中文
import pytest
import allure
from common.ComLog import LOGGER
from testdata import test_expend_data
@allure.epic("记账模块测试")
@allure.feature("支出功能的测试")
class TestExpendClass:
"""
支出测试用例类
"""
@pytest.mark.parametrize('test_somke_data',test_expend_data.test_somke_datas,ids=test_expend_data.test_smokecase_titles)
@pytest.mark.smoke
def test_expend_smoke(self,test_somke_data):
"""记账冒烟测试用例
"""
print(test_somke_data)
with allure.step("步骤1.1 记账前记录初始值,流水初始值"):
pass
with allure.step("步骤1.2 记账前记录初始值,账户初始值"):
pass
with allure.step("步骤1.3 记账前记录初始值,图表初始值"):
pass
with allure.step("步骤2 记账"):
pass
with allure.step("步骤3.1 记账后记录最终值,流水"):
pass
with allure.step("步骤3.1 记账后记录最终值,账户"):

本文介绍了在使用Pytest进行自动化测试时遇到的中文参数编码显示为u6d4b等问题,通过在项目根目录创建conftest.py文件并添加特定代码,成功解决了测试用例参数别名和Allure报告中中文显示不正确的问题。
最低0.47元/天 解锁文章
1550

被折叠的 条评论
为什么被折叠?



