<15>pytest:测试用例中文命名
目录:测试自动化学习 - pytest
说明:本篇博客基于pytest 6.2.5
问题
使用中文命名用例,出现乱码
解决方案
conftest.py文件中,hook所有用例,修改编码方式
from typing import List
def pytest_collection_modifyitems(session: "Session", config: "Config", items: List["Item"]) -> None:
for item in items:
item.name = item.name.encode('utf-8').decode("unicode-escape")
item._nodeid = item.nodeid.encode('utf-8').decode("unicode-escape")
{{uploading-image-467054.png(uploading...)}}

浙公网安备 33010602011771号